Forum Discussion
charlie4872
Jun 18, 2020Brass Contributor
Using Remote $env user variable with invoke-command not working
In short, the script below is taking the $env:APPDATA info from my local computer instead of the $env:APPDATA info for the user currently logged on at remote computer, specified in the $computer vari...
Erick A. Moreno R.
Jun 21, 2020Iron Contributor
charlie4872 Hello Charlie. You can try to get the variable from the remote machine with this.
$computer = read-host 'Enter Computer Name'
invoke-command -computer $computer -scriptblock {Remove-Item -recurse "$([Environment]::GetEnvironmentVariable(“APPDATA”))\Microsoft\Teams\blob_storage\*"}
Regards
Erick Moreno
gastone
Jun 27, 2020Brass Contributor