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 variable. I have tried with no luck to search this in Google so I thought I would post here to see if anyone can help. Driving me crazy. Let me know if anything doesn't make sense.
Thanks in advance!
$computer = read-host 'Enter Computer Name'
invoke-command -computer $computer -scriptblock {Remove-Item -recurse "$env:APPDATA\Microsoft\Teams\blob_storage\*}