Forum Discussion
mattyHip
Dec 28, 2021Copper Contributor
Trying to copy files from network share while running a remediation script in Intune
I need to copy a file from the network share to the C:\windows\temp folder, then install the software on the local machine using the proactive remediation script. All of our software installation fil...
mattyHip
Dec 28, 2021Copper Contributor
Rudy_Ooms_MVP Just to validate that this method works. Thanks for pointing out a user account to handle the network share permissions
$password = ConvertTo-SecureString "p@ssw0rd" -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ("domain.com\adminAccount", $password)
$alternateUsers = [scriptblock]{
Copy-Item -Path (Join-Path -Path "\\sharedDrive.com\util\software\FreshService\2.9 Agent" -ChildPath "fs-windows-agent-2.9.0.msi") -Destination "C:\windows\temp\fs-windows-agent-2.9.0.msi"
}
# https://www.itdroplets.com/run-a-command-as-a-different-user-in-powershell/
$GetProcessJob = Start-Job -ScriptBlock $alternateUsers -Credential $Cred
Wait-Job $GetProcessJob
$GetProcessResult = Receive-Job -Job $GetProcessJob
Write-Output $GetProcessResult
#Will set timer/timeout function
#if($GetProcessResult.state -eq "Completed"){
Start-Process "C:\windows\temp\fs-windows-agent-2.9.0.msi" -ArgumentList "/i /qn"
#}
Dec 29, 2021
Hi, So you managed it go get it to work? If so nice to hear. Like mentioned ealier, that password will show up plain text in your log files on the device itself. so be carefull with it π
If it's sensative info, maybe removing it from the log afterwards
https://call4cloud.nl/2021/05/the-laps-reloaded/#third-part
If it's sensative info, maybe removing it from the log afterwards
https://call4cloud.nl/2021/05/the-laps-reloaded/#third-part