Using a Variable (PowerShell) inside of a command

前端 未结 1 779
失恋的感觉
失恋的感觉 2020-11-30 14:35
$computer = gc env:computername

# Argument /RU \'$computer\'\\admin isn\'t working.
SchTasks /create /SC Daily /tn \"Image Verification\" /ST 18:00:00 /TR C:\\bdr\\         


        
相关标签:
1条回答
  • 2020-11-30 14:50

    Single quoted strings will not expand variables in PowerShell. Try a double quoted string e.g.:

    "$computer\admin"
    
    0 讨论(0)
提交回复
热议问题