Redirect in PowerShell

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Redirect in PowerShell

Post by Don Wells »

I ran the following command line in PowerShell and it provided the expected results.

Code: Select all

Get-WmiObject -Class "win32_quickfixengineering" 
I attempted to redirect the output with the following, and of course it failed.

Code: Select all

Get-WmiObject -Class "win32_quickfixengineering" > "C:\Updates.txt"
Can someone steer me in the right direction; please.
:scratch:
Many thanks in advance.
Regards
Don

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Redirect in PowerShell

Post by Rudi »

Outright guess, but would this work?

Code: Select all

Get-WmiObject -Class "win32_quickfixengineering" > C:\Updates.txt
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Redirect in PowerShell

Post by Don Wells »

Thanks for driving me back for another attempt Rudy. Our intuition was correct in that the DOS redirect works in PowerShell. My problem was lack of access to the root directory. The following script created the file in my current directory.

Code: Select all

    Get-WmiObject -Class "win32_quickfixengineering" > "Updates.txt"
Since there are no spaces in the filename, it works just as well without the quotes.
Regards
Don

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Redirect in PowerShell

Post by Rudi »

TX for the feedback. :thumbup:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.