I am new to power-shell and getting one problem.
My problem is :- I have to get the folders/files from shared location to local machine (Machine 1). I have written this script in power-shell file and placed this file on another machine (Machine 1). Now when I am trying to execute this power-shell file from my machine (Machine 2) by using credentials, but it says that "Access is denied" while accessing the shared location.
It's working fine if I directly executes the power-shell file on (Machine 1). Following is the script that I am trying to execute from Machine 2 :-
[cmdletBinding(SupportsShouldProcess=$true,ConfirmImpact="High")]
param
(
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string]$ComputerName,
[parameter(Mandatory=$false)]
[System.Management.Automation.PSCredential]$Credential
)
begin
{
if (!($Credential))
{
# Prompt for crede;ntials if not passed in
$Credential = get-credential
}
Invoke-Command -ComputerName $computerName -Credential $credential -ScriptBlock {
F:\Untitled2.ps1
}
}
Following is the script that I am trying to execute from Machine 1
robocopy [shared location] [local machine folder] /MIR /COPY:DT /FFT
Is this a admin-right issue or some thing else I have to mention in script. Please help me out from this issue.
Thanks in Advance !!
Prateek