Solved

Need Help with PowerShell String

Posted on 2014-11-26
8
483 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 70

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
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 

Author Comment

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

Accepted Solution

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

737 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