Solved

Need Help with PowerShell String

Posted on 2014-11-26
8
464 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

830 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