I launched a couple servers in AWS and I want to read the contents of the a file using Powershell.
On server 1 I create a file called App_configuration.txt
and placed in the root of c:\
.
The file has just 2 lines in it:
<Path>C:\GoodToGo</Path>
<Path>C:\GoodToGo2</Path>
I'm trying to access the file with this command using the remote IP of the server. The xx.xxx.xx.xxx
is supposed to be the remote IP:
Get-Content -Path "\\xx.xxx.xx.xxx\c$\App_configuration.txt"
Get-Content : Cannot find path '\\xx.xxx.xx.xxx\c$\App_configuration.txt' because it does not exist.
At line:1 char:1
+ Get-Content -Path "\\xx.xxx.xx.xxx\c$\App_configuration.txt"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\xx.xxx.xx.xxx\c$\App_configuration.txt:String) [Get-Content], ItemNot
FoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
I can RDP into the remote server and list the file:
PS C:\> ls C:\App_configuration.txt
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 3/2/2021 4:12 PM 51 App_configuration.txt
I am not the same user on my local machine as the one that can log into the remote machine. The server I am trying to access is in AWS, and I am trying to access it from my local machine.
I have the powershell port 5985
open on the AWS security group (firewall) and I can connect to it remotely using telnet.
Why can't I read this remote file with this powershell line? I think the issue might be network related.
\\xx.xxx.xx.xxx\c$\
on the machine you run the PowerShell from, are you able to open that file and read from it that way? You will need that level of access or to enter a credential to authenticate to that resource and then run the command. You can also consider running invoke-command and running the process that way from the local file system path and not the hidden C$ admin share. I can think of a few ways to tackle this process depending on your configuration and authentication hop needs, and so forth.c$
share and the local file system: `c:` no problem. Thanks for your help!\\ipaddress\c$
to be accessible. Furthermore, the credential you authenticate against the\\ipaddress\c$
"remotely" but be a local administrator on the AWS server. With those two things, you should be able to access the Windows C$ hidden admin share no problem remotely. Otherwise, you'd need to authenticate and/or open the protocol/ports to be allowable inbound for the network zone from the OS perspective. Usinginvoke-command
may be better than C$ for you tho