1

I want remotely to change login screen for a couple of laptops. I manage to do everything beside copy the image from my PC to the target PC.

All the laptops have setup of the fallowing

Enable-PSRemoting -Force    
set-item wsman:\localhost\Client\TrustedHosts -Value 192.168.10.10    
Restart-service WinRM

I have try to enable CredSSP to perform the copy-item command, but it seems to work only on PowerShell v3.0 or I miss configured something for Powershell v2.0 To make this work on v2.0 I have to manually enter Enable-WSManCredSSP -role server on my target computer (the client role does not seems to work like in v3.0)

On v3.0 I make this possible by the following commands

$cred = Get-Credential
Invoke-Command -ScriptBlock { Enable-WSManCredSSP -Role Client -DelegateComputer * } -ComputerName 192.168.10.12 -Credential $cred

And I get

Do you want to enable CredSSP authentication?
[Y] Yes  [N] No [?] Help (default is "Y"): y
Access is denied.
    + CategoryInfo          : InvalidOperation: (System.String[]:String[]) [Enable-WSManCredSSP], InvalidOperationExce ption
    + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.EnableWSManCredSSPCommand
    + PSComputerName        : 192.168.30.81

But if I try that on windows 8 with Powershell v3.0 it does the command without giving me Access Denied. If there is any other way to do the task on PowerShell v2.0 its still relevent for me.

Vasil Nikolov
  • 667
  • 6
  • 16
  • try to set trustedhosts and computername with the hostname instead of the ip, i experienced similar problems with winrm and using the hostname instead of ip address fixed it – Paul Oct 21 '14 at 15:33
  • Even with Host name instead, I get the same result. – Vasil Nikolov Oct 21 '14 at 16:19
  • then you have to continue your hunt, good luck – Paul Oct 21 '14 at 16:26
  • Possible workaround: unless you have default admin shares disabled, you don't need WinRM for Copy-Item. Use UNC path as the destination, for instance: `Copy-Item C:\folder\file.txt \\host\C$\folder` – Alexander Obersht Oct 21 '14 at 17:52
  • Really good hint @Alexander , thank you. But I get access denied, and when I try to add credentials it says `The FileSystem provider supports credentials only on the New-PSDrive cmdlet.` – Vasil Nikolov Oct 23 '14 at 08:20

1 Answers1

1

I found a solution another way around. Instead of CredSSP connection I used method of New-PSDrive , but for Powershell v2.0 there is a bug with the credentials - more information about it in the link : PowerShell v2.0 Bug

I used the workaround solution from the link above :

$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("u:", "\\server\share", $false, "domain\user", "password")

That code will made a virtual drive linked to the share drive that I want to use, and then when I want to copy file from a remote share I use the virtual drive as local.

Example:

Copy-Item -Force 'U:\backgroundDefault.jpg'  "C:\Windows\System32\oobe\info\backgrounds\"

I found the answer from another topic in stackoverflow New-PSDrive does not support credentials?

Community
  • 1
  • 1
Vasil Nikolov
  • 667
  • 6
  • 16