I have a PS script that runs that invokes a vbs script. This works fine until I try to include the -computername attribute. When I do that I get an Access is denied error.
Script:
$computerName = Read-Host "Computer Name: " $employeecode = Read-Host "Employee Code: " Invoke-Command -ScriptBlock { cscript.exe \\serverpath\UserPrintersScrape.vbs $computerName $employeecode } -ComputerName $computerName
When I run it, i get this error:
CScript Error: Loading script "\\serverpath\UserPrintersScrape.vbs" failed (Access is denied. ).
However if I run this it runs fine:
$computerName = Read-Host "Computer Name: " $employeecode = Read-Host "Employee Code: " Invoke-Command -ScriptBlock { cscript.exe \\serverpath\UserPrintersScrape.vbs $computerName $employeecode }
The problem is, I need this to run on a remote pc. Any thoughts on how to resolve this or what is causing it?
Edit: One other thing to note, when I add the -computername I run it on my local pc for testing and get the error.
- Edited by RubberDuck13 10 hours 0 minutes ago