1

I tried with below script in local machine to run remote powershell script which is located in remote azure vm.

I'm able to connect to azure remote vm through powershell pssession, but Invoke-Command is not returning anything. Unable to run remote powershell script.

enter image description here

I tried as below aswell

enter image description here

But -FilePath trying to look into local machine D: drive instead of remote azure vm D: drive.

How to run remote azure vm powershell script which is located in remote azure vm D: drive

S.Chandra Sekhar
  • 453
  • 3
  • 11
  • 22
  • Please do not add code as images. Instead, edit the question and add the code as formatted text. – Theo Apr 04 '20 at 19:30

2 Answers2

0

My guess is that the fault probably lies in your GetRemoteAzureVMHstName.ps1 script.

make sure it's actually printing something.

ingenium21
  • 55
  • 1
  • 10
  • My remote powershell script has bolt commands similar to https://stackoverflow.com/questions/60956833/how-to-run-puppet-bolt-command-remotely-on-azure-virtual-machine-through-powersh?noredirect=1#comment107890565_60956833 to get another remote vm hostname. – S.Chandra Sekhar Apr 05 '20 at 00:56
0

My script is working fine now.

In Invoke-Command, for -Command I removed single quotes for script file path and it worked.

Invoke-Command should be as below

Invoke-Command -Session $s -Command { D:\User1\GetRemoteAzureVMHstName.ps1 }

instead of below

Invoke-Command -Session $s -Command { 'D:\User1\GetRemoteAzureVMHstName.ps1' }
S.Chandra Sekhar
  • 453
  • 3
  • 11
  • 22