Problems using "RunAs" in powershell - windows

I am trying to access powershell from another user (user2), but at the same time I also want to access the resources of my main user (user1), I have a virtual environment, windows server 2022 and a windows 10 pro machine, in which I am doing the following:
Right click on the powershell icon > Run as another user, then I access user 2 to which I want to connect with their respective credentials.
Once this is done in powershell I execute the following:
runas /user:corp\user2 /netonly powershell
Then, I put the credentials again and navigate to the path of my main user(user1) and when I execute "ls", it gives me the following error:
ls : Access denied to path 'C:\Users\user1'.
At line:1 char:14
+ ls
+ ~~
+ CategoryInfo : PermissionDenied: (C:\Users\user1:String) [Get-ChildItem], UnauthorizedAccessExcepti
on
+ FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand

Related

CMD.exe and Powershell.exe cannot generate ssh keys using ssh-keygen

Hope you can help me out here. I've been playing around with some SSH authentication. I have no idea why this is happening, but now when I run a simple ssh-keygen command I get a response saying Access is denied. in addition to a pop-up that reads "This app can't run on your PC. To find a version for your PC, check with the software publisher".
I then tried running the ssh-keygen command in Powershell (as admin and as regular user) and got the following:
Program 'ssh-keygen.exe' failed to run: The specified executable is not a valid application for this OS platform.At
line:1 char:1
+ ssh-keygen
+ ~~~~~~~~~~.
At line:1 char:1
+ ssh-keygen
+ ~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
However, using ssh -V shows that it is installed:
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
I can still SSH fine into other devices, if that's of any relevant.
Any help would be very much appreciated here!

Configure a GCP Filestore on a GCP Windows Instance

I've been trying to mount the Google Filestore and use as a NFS Shared volume on two of my GCP Windows VM instances but I keep getting the error below. Any assistance is much appreciated. I need to figure this one out.
PS C:\Windows\system32> mount 10.*.***.250:/logs_arcon D:\Storage
cmdlet New-PSDrive at command pipeline position 1
Supply values for the following parameters:
Root: D:\
mount : Cannot find a provider with the name 'D:\Storage'.
At line:1 char:1
+ mount 10.42.144.250:/logs_arcon D:\Storage
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (D:\Storage:String) [New-PSDrive], ProviderNotFoundException
+ FullyQualifiedErrorId : ProviderNotFound,Microsoft.PowerShell.Commands.NewPSDriveCommand
The format of your command mount 10.42.144.250:/logs_arcon D:\Storage doesn't look to be aligned with the provided in the documentation examples.
The format shown in the docs should work:
mount 10.0.0.2:/vol1 z:

Windows services not visible remotely

I'm struggling to figure out what is going on, but it has a pretty widespread effect on a system I'm working with.
I have several machines running a service, but when I try to query the service (both in .net and in powershell) the service is not found. When I connect to the machine via RDP, the service shows up. I've already confirmed that I had permissions on the service, including granting explicit permissions to the service for my user using subinacl.
I do get a result back from get-service -computername $server but it doesn't list the service I'm looking for. Is there a group policy or windows configuration that I'm missing here? Why would some services show up remotely but not all of them?
Any tips/advice on what to look for would be greatly appreciated.
EDIT: Using this command:
get-Service -computername $servername | Export-Csv C:\temp\Local.csv -notypeinformation
On the machine yields the following file:
https://drive.google.com/open?id=1aXvIgWT4NU2EN4j14JlxrY-jHGp-hG2Q
Running the same command remotely against the machine yields the following file:
https://drive.google.com/open?id=16NvRgrQsSGc9CKlqmIqntLy1bkLMl5tJ
EDIT2:
Command:
Get-Service -Computername $servername -Name 'AdobeARMservice'
Running Remotely Result:
Get-Service : Cannot find any service with service name
'AdobeARMservice'. At line:1 char:1
+ Get-Service -Computername $servername -Name 'AdobeARMservice'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (AdobeARMservice:String) [Get-Service], ServiceCommandExcep
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
Running Locally Result:
Status Name DisplayName
------ ---- -----------
Running AdobeARMservice Adobe Acrobat Update Service
Edit3:
This issue can also be seen in the microsoft service list.
While locally on the machine:
While remote:
The powershell documentation for get-service says:
This cmdlet can display services only when the current user has
permission to see them. If this cmdlet does not display services, you
might not have permission to see them.
I would therefore assume that your remote user is a different user than the local user.
if you truly have access rights, you could just do this instead
invoke-command -computername $servername -scriptblock {get-service} | export-csv C:\temp\Local.csv -notypeinformation

Configuring Shell Environment for Windows 8.1

Configure the shell environment for the CDB (orcl) and set the TWO_TASK variable to the PDB (pdborcl)
. oraenv
export TWO_TASK=pdborcl
sqlplus sys/password as sysdba
I got the link from here
The above instructions are vital to enable me install sample HR schema on my oracle 12c database(Home PC) for training on Windows 8.1.
I have tried running the commands using the prefix SET in windows power-shell and CMD (admin privileges) but no positive results.
I am aware that in order to set the TWO_TASK....I can achieve this by setting these parameters in windows environment or using CMD.
UPDATE WITH SOME CODE:
C:\WINDOWS\system32> SET oraenv
C:\WINDOWS\system32> SET export TWO_TASK=pdborcl
C:\WINDOWS\system32> SET sqlplus sys/1Ihavenone as sysdba
Set-Variable : A positional parameter cannot be found that accepts argument 'as'.
At line:1 char:1
+ SET sqlplus sys/1Masupalami as sysdba
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Variable], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetVariableCommand
1Ihavenone sys password and works fine in connect to CDB$ROOT –

Varying permissions on Windows Server based on method of authenticating

I'm running into a weird issue here.
I have a Windows server setup to allow SSH access via Cygwin.
The idea behind this is to allow me to remotely execute Powershell commands from one of my Linux boxes. Now, in the hopes of being secure while still allowing for automation, I did your typical ssh-copy-id to my designated account on that box. I then tried logging in via SSH keys... success! Now here's the weird part. I run my Powershell command:
powershell 'C:/cygwin64/scripts/add_email_address_to_distribution_list.ps1'
And get the following error message:
$ powershell
'C:/cygwin64/scripts/add_email_address_to_distribution_list.ps1'
Add-DistributionGroupMember : Value cannot be null. Parameter name:
serverSettings At
C:\cygwin64\scripts\add_email_address_to_distribution_list.ps1:2
char:28
+ Add-DistributionGroupMember <<<< -Identity some_distribution_list -Member user# domain.com
+ CategoryInfo : NotSpecified: (:) [Add-DistributionGroupMember],
ArgumentNullException
+ FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.
Management.RecipientTasks.AddDistributionGroupMember
Now if I remove the pubkey from my account's .authorized_keys file, login with my usual password, and retry... the script works!
I'm stumped as to why authentication via password over SSH allows for the script to run successfully , while authentication via keys over SSH doesn't.
Any ideas?
EDIT:
Here's the script that's being run:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Add-DistributionGroupMember -Identity some_distribution_list -Member user#domain.com

Resources