Forum Discussion
TylerCam
Jul 17, 2024Copper Contributor
Invoke-command Access denied on Windows 11 but works with Windows 10
I'm trying to connect to a remote computer using Invoke-Command while running an elevated Powershell ise. I recently upgraded to Windows 11 and my scripts no longer work and are giving me an Access i...
- Jul 24, 2024Got this figured out. Had to change it with New-PSdrive:
$Creds = Import-CliXml -Path "C:\Install\PowerCreds\Cred.xml"
Invoke-Command -ComputerName $Computer -Credential $Creds -ScriptBlock {
New-PSDrive -Credential $Using:Creds -Name Powershell -PSProvider FileSystem -Root "\\network\folder\" | Out-Null
Test-Path "\\network\File\Location\"
Remove-PSDrive -Name Powershell -Force
}
So adding the New-PSdrive then removing it at the end of the Invoke-Command, still inside it, allowed the credentials to be passed without any problems.
TylerCam
Jul 24, 2024Copper Contributor
Got this figured out. Had to change it with New-PSdrive:
$Creds = Import-CliXml -Path "C:\Install\PowerCreds\Cred.xml"
Invoke-Command -ComputerName $Computer -Credential $Creds -ScriptBlock {
New-PSDrive -Credential $Using:Creds -Name Powershell -PSProvider FileSystem -Root "\\network\folder\" | Out-Null
Test-Path "\\network\File\Location\"
Remove-PSDrive -Name Powershell -Force
}
So adding the New-PSdrive then removing it at the end of the Invoke-Command, still inside it, allowed the credentials to be passed without any problems.
$Creds = Import-CliXml -Path "C:\Install\PowerCreds\Cred.xml"
Invoke-Command -ComputerName $Computer -Credential $Creds -ScriptBlock {
New-PSDrive -Credential $Using:Creds -Name Powershell -PSProvider FileSystem -Root "\\network\folder\" | Out-Null
Test-Path "\\network\File\Location\"
Remove-PSDrive -Name Powershell -Force
}
So adding the New-PSdrive then removing it at the end of the Invoke-Command, still inside it, allowed the credentials to be passed without any problems.