سؤال

I've created a small PowerShell script to remove a Autodesk application. However, PowerShell doesn't seam to like system variables like %username%. Whats the best way of achieving this in Powershell?

 # Remove all Autodesk products from a Windows System 
 $AutoDeskPaths = "C:\Users\%username%\AppData\Roaming\Autodesk", "C:\Users\%username%\AppData\Local\Autodesk", "C:\ProgramData\Autodesk", "C:\Program Files\Autodesk\AutoCAD 2012", "C:\Program Files\AutoCAD 2010", "C:\Program Files\Common Files\Autodesk Shared","HKCU:Software\Autodesk", "HKLU:Software\Autodesk"
 Remove-item $AutoDeskPaths -Recurse
هل كانت مفيدة؟

المحلول

You can access environment variables like this:

$Env:UserName
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top