RE: [powershell] RE: PowerShell.exe from cmd - WMI filter quotes

2017-06-06 Thread Daniel Ratliff
I would use the built in environment variables, but am running in a SCCM OSD task sequence and prefer the TS variables over environment variables. Two solutions that would work, thanks again guys. Daniel Ratliff From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Be

RE: [powershell] RE: PowerShell.exe from cmd - WMI filter quotes

2017-06-06 Thread Eric Laizure
Devin beat me to it. ☺ Also, you may want to change %Hostname% to $($Env:COMPUTERNAME), otherwise your file will literally be %Hostname%_printers.csv. Eric Laizure From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of Devin Rich Sent: Tuesday, June 6, 2017 9

Re: [powershell] RE: PowerShell.exe from cmd - WMI filter quotes

2017-06-06 Thread Devin Rich
I think Eric's works, you just missed the opening ' before Portname. :) I like Where-Object, but if I need server side performance, then I will use -Filter (typically with large AD domains). Thanks, Devin Rich Systems Administrator On Tue, Jun 6, 2017 at 10:10 AM, Daniel Ratliff wrote: > It do

[powershell] RE: PowerShell.exe from cmd - WMI filter quotes

2017-06-06 Thread Daniel Ratliff
Devin's suggestion did the trick! I hadn't even considered reverting to where-object. Thanks everyone!! Daniel Ratliff From: Daniel Ratliff Sent: Tuesday, June 6, 2017 12:11 PM To: powershell@lists.myitforum.com Subject: RE: PowerShell.exe from cmd - WMI filter quotes It doesn't like that one.

[powershell] RE: PowerShell.exe from cmd - WMI filter quotes

2017-06-06 Thread Daniel Ratliff
It doesn't like that one. Trying Devin's suggestion now. [cid:image002.png@01D2DEBD.E96066C0] Daniel Ratliff From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of Eric Laizure Sent: Tuesday, June 6, 2017 11:53 AM To: powershell@lists.myitforum.com Subject: [p

[powershell] RE: PowerShell.exe from cmd - WMI filter quotes

2017-06-06 Thread Eric Laizure
Try this. Since this is being executed from Batch or just the command line, you can't use but 1 double quote. You have to split it out into 2 single quote marks. At least, that's how I've had to do something similar to this. powershell.exe -executionpolicy bypass -command "& {Get-WmiObject win32

Re: [powershell] PowerShell.exe from cmd - WMI filter quotes

2017-06-06 Thread Devin Rich
Are there enough entries in the win32_printer list to merit NEEDING to use -filter? Yes, it is faster than a Where-Object, but I have less than 10 printers on my print server and I don't notice an execution difference. Here's what I ran: powershell.exe -executionpolicy bypass -command "& {Get-WmiO

[powershell] PowerShell.exe from cmd - WMI filter quotes

2017-06-06 Thread Daniel Ratliff
Any ideas on how to get around this? I have played around with the backtick, double quotes, single quotes, and cannot seem to find a working syntax. It is failing on the WMI filter. powershell.exe -executionpolicy bypass -command "& {Get-WmiObject win32_printer -Filter "PortName LIKE '%.%.%.%'"