Salve a tutti e complimenti per il sito. Ho creato uno script che viene eseguito in remoto su ognuno degli host di mio interesse. Questo script effettua una serie di operazioni sulla macchina remota e genera un file che deve essere, alla fine dell'elaborazione, copiato in locale sul mio PC.
Questo è il comando che lancio dalla PS del mio PC; dfsdir.ps1 è lo script che voglio eseguire in remoto sul server cxfsh01
invoke-command -comp cxfsh01 -filepath .\dfsdir.ps1
Funziona tutto tranne la copia dalla macchina remota cxfsh01 al mio PC
$FOLDERS = "c:\temp"
$WORKINGFOLDER = Get-Location | Convert-Path
$DESTINTATIONFILE = "\esito.txt"
$OUTPUTFILE = $WORKINGFOLDER + $DESTINTATION
# Copia il file sulla destinazione
Copy-Item $OUTPUTFILE -Destination "\\miopc\transito\esito.txt" -Verbose
L'errore è il seguente:
Access to the path '\\miopc\transito\esito.txt' is denied.
+ CategoryInfo : PermissionDenied: (C:\Users\mioutente....ments\esito.txt:FileInfo) [Copy-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
Ho provato anche ad usare le credenziali...in questo caso l'errore è:
The provider does not support the use of credentials. Perform the operation again without specifying credentials.
+ CategoryInfo : NotImplemented: (:) [], PSNotSupportedException
+ FullyQualifiedErrorId : NotSupported
Quindi desumo che non servono.
Se mi collego in remote desktop sul server remoto e da PS faccio la stessa operazione lanciando a mano il comando tutto funziona.
Qualcuno ha dei suggerimenti? Google non mi ha aiutato.
Grazie in anticipo.