I want to create a file with PowerShell and did it but I can not run this script from batch file. It just working on where is script located but I want to run this script another machine.
Batch file
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""\\169.254.137.118\Shared\Greetings.ps1""' -Verb RunAs}"
PowerShell file
New-Item C:\Test.txt
Verb Runas
parameters?PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""\\169.254.137.118\Shared\Greetings.ps1""' -Verb RunAs}"
and also try that same format without the-Verb RunAs
and see what happens. Perhaps you need to bypass execution policy on the initial call before the other powershell call within it.