Help in using a path on a variable to execute a command (SOLVED)

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Vandrey Trindade Vandrey Trindade 9 months, 3 weeks ago.

  • Author
    Posts
  • #35270
    Profile photo of Vandrey Trindade
    Vandrey Trindade
    Participant

    Hi,

    I'm trying to execute that command below:

    `
    PS C:\> $Usuario = "E:\users\thardy"
    PS C:\> Invoke-Command -ComputerName SRVAD -ScriptBlock {dirquota quota scan /path:$Usuario}
    The specified path is invalid.
    PS C:\>
    `

    How can I make that in a way that the variable can be used for the command, no matter what path I type on it... (E:\, E:\temp, E:\users\userabc, etc...)

  • #35271
    Profile photo of Don Jones
    Don Jones
    Keymaster

    See https://powershell.org/kb/remote-variables-and-invoke-command/. Your variable has no meaning on the remote computer.

  • #35272
    Profile photo of Vandrey Trindade
    Vandrey Trindade
    Participant

    Don Jones,

    Perfect solution! Thanks a lot for the quick reply!

You must be logged in to reply to this topic.