Solved

Need Help with PowerShell String

Posted on 2014-11-26
8
457 Views
Last Modified: 2014-11-26
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….  

Copy-Item -Path "\\Server\mbam" -Destination "\\Server\C$" -Credential $Creds

Open in new window


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], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand


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], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand
0
Comment
Question by:amstoots
  • 4
  • 3
8 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 40467949
You posted the same statement and error message twice.

Remember that you need to be an admin group member to get access to C$.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40467953
\\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$"
0
 

Author Comment

by:amstoots
ID: 40467961
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 : GetDynamicParametersException,Microsoft.PowerShell.Commands.CopyItemCommand
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:amstoots
ID: 40467984
Its a folder that I need to move over instead of a file.
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40468085
copy-item \\server\mbam\* \\server\c$\ -recurse
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40468086
"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.
0
 

Author Comment

by:amstoots
ID: 40468260
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...
0
 

Author Closing Comment

by:amstoots
ID: 40468365
thanks for your help
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question