I use below batch script to copy a file from USB to Downloads of a current user. What should it be if I want to apply this in Powershell ? Please help.
The difficult part is to interpret these two %~dp0 and %userprofile% The destination profile should be current user profile not administrator profile if powershell is run in administrator.
Copy-Item -Path %~dp0Software\Browsers\ChromeStandaloneSetup64.exe" -Destination %userprofile%\downloads
$Env:USERPROFILEfor the other thing. Not sure about running it as administrator. Maybe code the script to call the script dynamically with$Env:USERPROFILEas an argument and have the script elevate as administrator and use that first passed$args[0]as a variable to fill in the destrination path portion of the logic. Give some of these things a test and see how it goes for some quick GoogleFu and thoughts. https://ss64.com/ps/syntax-args.html – Vomit IT - Chunky Mess Style Aug 28 '22 at 02:56