How to pass a variable as an argument to a command with quotes in powershell
        Posted  
        
            by da_ponc
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by da_ponc
        
        
        
        Published on 2010-04-22T01:42:16Z
        Indexed on 
            2010/04/22
            1:43 UTC
        
        
        Read the original article
        Hit count: 353
        
Hi there,
My powershell script takes the following parameter:
Param($BackedUpFilePath)
The value that is getting passed into my script is:
"\123.123.123.123\Backups\Website.7z"
I have another variable which is the location I want to extract the file:
$WebsiteDeploymentFolder = "C:\example"
I am trying to extract the archive with the following command:
`7z x $BackedUpFilePath -o$WebsiteDeploymentFolder -aoa
I keep getting the following error:
Error: cannot find archive
The following works but I need $BackedUpFilePath to be dynamic:
`7z x '\123.123.123.123\Backups\Website.7z' -o$WebsiteDeploymentFolder -aoa
I think I need to pass $BackedUpFilePath to 7z with quotes but they seem to get stripped out no matter what I try. I am in quote hell.
Thanks.
© Stack Overflow or respective owner