Solved

Need Help with PowerShell String

Posted on 2014-11-26
8
432 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 68

Expert Comment

by:Qlemo
Comment Utility
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
Comment Utility
\\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
Comment Utility
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
 

Author Comment

by:amstoots
Comment Utility
Its a folder that I need to move over instead of a file.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
copy-item \\server\mbam\* \\server\c$\ -recurse
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
"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
Comment Utility
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
Comment Utility
thanks for your help
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now