I want to run remotely some programs on Azure windows server from a windows machine using windows powershell remote. It was configured and I can do copy, delete, add and get process and etc.. but i can not run any program such as .cmd , .txt, ... on remote Azure VM. I don't get any error.
I tried Invoke-item, Invoke-process, ... for executing. I will appreciate if you help me.
Br,
Based on my knowledge, we can't use invoke-item
to open file in powershell remote session.
When we run Invoke-Item "c:\test1.txt"
, we can't open this txt file in powershell session(no interaction), but this process run in background, we can use gps
to get it, like this:
According to your description, we can run .cmd
in Powershell remote session, like this:
PS C:\Users\Administrator> Enter-PSSession -ComputerName 40.71.248.64 -Credential jason
[40.71.248.64]: PS C:\Users\jason\Documents> cd c:\
[40.71.248.64]: PS C:\> .\test.cmd
C:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : jason
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : ym3volvuiu2uvkfm320g2dyokd.bx.internal.cloudapp.net
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . : ym3volvuiu2uvkfm320g2dyokd.bx.internal.cloudapp.net
Description . . . . . . . . . . . : Microsoft Hyper-V Network Adapter
Physical Address. . . . . . . . . : 00-0D-3A-19-04-EA
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::9c7d:4c97:bcfc:2914%18(Preferred)
IPv4 Address. . . . . . . . . . . : 10.0.0.4(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Wednesday, June 28, 2017 12:12:27 AM
Lease Expires . . . . . . . . . . : Saturday, August 4, 2153 2:19:12 PM
Default Gateway . . . . . . . . . : 10.0.0.1
DHCP Server . . . . . . . . . . . : 168.63.129.16
DHCPv6 IAID . . . . . . . . . . . : 301993274
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-20-E4-AC-C2-00-0D-3A-19-04-EA
DNS Servers . . . . . . . . . . . : 168.63.129.16
NetBIOS over Tcpip. . . . . . . . : Enabled