Mike
asked on
Need Help with PowerShell String
Greeting Experts:
I need help with a String to copy a file from one remote “source” computer “source” (Network Share “localhost\Share”) to the remote “Destination” computer” (Network Share “localhost\C$”). When I attempt to use the following PowerShell string (Copy-Item -Path "\\Server\mbam" -Destination \\Server\C$) I get the following error (marked No#1 below) getting access denied for Destination computer.. When I attempt to use (Copy-Item -Path "\\Server\mbam" -Destination \\Server\C$ -Credential $Creds) I get a different error message (marked NO#2 below). Can somebody Please give me in idea of what I am doing wrong and what I can do to correct it….
Error message one: with out Credentials
Copy-Item : Access is denied
At line:1 char:1
+ Copy-Item -Path "\\server\mbam" -Destination "\\server\C$" -Credential $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessExceptio n
+ FullyQualifiedErrorId : System.UnauthorizedAccessE xception,M icrosoft.P owerShell. Commands.C opyItemCom mand
Error message 2: Using Credentials ( i.e. Domain\User)
Copy-Item : Access is denied
At line:1 char:1
+ Copy-Item -Path "\\server\mbam" -Destination "\\server\C$" -Credential $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessExceptio n
+ FullyQualifiedErrorId : System.UnauthorizedAccessE xception,M icrosoft.P owerShell. Commands.C opyItemCom mand
I need help with a String to copy a file from one remote “source” computer “source” (Network Share “localhost\Share”) to the remote “Destination” computer” (Network Share “localhost\C$”). When I attempt to use the following PowerShell string (Copy-Item -Path "\\Server\mbam" -Destination \\Server\C$) I get the following error (marked No#1 below) getting access denied for Destination computer.. When I attempt to use (Copy-Item -Path "\\Server\mbam" -Destination \\Server\C$ -Credential $Creds) I get a different error message (marked NO#2 below). Can somebody Please give me in idea of what I am doing wrong and what I can do to correct it….
Copy-Item -Path "\\Server\mbam" -Destination "\\Server\C$" -Credential $Creds
Error message one: with out Credentials
Copy-Item : Access is denied
At line:1 char:1
+ Copy-Item -Path "\\server\mbam" -Destination "\\server\C$" -Credential $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessExceptio
+ FullyQualifiedErrorId : System.UnauthorizedAccessE
Error message 2: Using Credentials ( i.e. Domain\User)
Copy-Item : Access is denied
At line:1 char:1
+ Copy-Item -Path "\\server\mbam" -Destination "\\server\C$" -Credential $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessExceptio
+ FullyQualifiedErrorId : System.UnauthorizedAccessE
\\Server\mbam is not a file/item...
Try using a server, share path, and file for your source. This appears to be simply a shared folder on the server.
Example:
Copy-Item -Path "\\Server\mbam\file.txt" -Destination "\\Server\c$"
Try using a server, share path, and file for your source. This appears to be simply a shared folder on the server.
Example:
Copy-Item -Path "\\Server\mbam\file.txt" -Destination "\\Server\c$"
ASKER
My mistake.... Here is the 2nd one
Copy-Item : Cannot retrieve the dynamic parameters for the cmdlet. The FileSystem provider supports credentials only on the New-PSDrive cmdlet.
Perform the operation again without specifying credentials.
At line:1 char:1
+ Copy-Item -Path "\\server\mbam" -Destination "\\server\C$" -Credential $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~
+ CategoryInfo : InvalidArgument: (:) [Copy-Item], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersExcept ion,Micros oft.PowerS hell.Comma nds.CopyIt emCommand
Copy-Item : Cannot retrieve the dynamic parameters for the cmdlet. The FileSystem provider supports credentials only on the New-PSDrive cmdlet.
Perform the operation again without specifying credentials.
At line:1 char:1
+ Copy-Item -Path "\\server\mbam" -Destination "\\server\C$" -Credential $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Copy-Item], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersExcept
ASKER
Its a folder that I need to move over instead of a file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"move"? Copy-Item does not move, only copy. And it does not check for updates, so if you need to do that more often, to keep a copy of the folder, you might consider using RoboCopy instead.
ASKER
the Item I having problems with is the Credentials $Creds function. when I attempt to excite the script. I get one of the two following error above...
ASKER
thanks for your help
Remember that you need to be an admin group member to get access to C$.