2

I have a script that has this code:

$secpasswd = ConvertTo-SecureString "Ukn545454" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ("$env:USERDOMAIN\user1", $secpasswd)
invoke-command -ComputerName "MyW10comp" -ScriptBlock {Start-proccess -FilePath PowerShell.exe -Credential $using:mycreds}

I have 8 computers, (one of them is also w10 but 32-bit) and on everyone of them the script runs well, but on of them Windows 10 64-bit it says:

This command cannot be run due to the error: Access is denied.
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    + PSComputerName        : MyW10Comp

If I am runnnig the script locally, everything goes well! What can I check on the computer to see what is the problem?

Thank you

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Lior
  • 139
  • 2
  • 13

1 Answers1

-1

This sounds like a double-hop problem. I don't understand why you would start a process passing credentials considering your session is already running in your context:

$cred = [pscredential]::new(
    'domain\user',
    ('pass' | ConvertTo-SecureString -AsPlainText -Force)
)

Invoke-Command -ComputerName MyW10comp -Credential $cred -ScriptBlock {
    Start-Process -FilePath cmd
}

This example should resolve your problem.

Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63
  • 3
    I will explain you more briefly what I want. I have a list of 8 computers, and on every computer I want to open Powershell with a custom credentials. So that means that the "Invoke-Command" will run with the user that I am currently using to run the script and to open powershell in the remote computer with the custom credentials So on all my computers it's working except Windows 10 64-bit :( – Lior Aug 12 '18 at 12:32