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 <dratl...@humana.com> wrote:

> It doesn’t like that one. Trying Devin’s suggestion now.
>
>
>
>
>
> *Daniel Ratliff*
>
>
>
> *From:* listsad...@lists.myitforum.com [mailto:listsadmin@lists.
> myitforum.com] *On Behalf Of *Eric Laizure
> *Sent:* Tuesday, June 6, 2017 11:53 AM
> *To:* powershell@lists.myitforum.com
> *Subject:* [powershell] RE: PowerShell.exe from cmd - WMI filter quotes
>
>
>
> 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_printer -Filter 'PortName LIKE ''%.%.%.%''' | select Name, PortName
> | ConvertTo-Csv -NoTypeInformation | out-file c:\temp\%Hostname%_printers.
> csv}"
>
>
>
>
>
> Eric Laizure
>
>
>
> *From:* listsad...@lists.myitforum.com [mailto:listsadmin@lists.
> myitforum.com <listsad...@lists.myitforum.com>] *On Behalf Of *Daniel
> Ratliff
> *Sent:* Tuesday, June 6, 2017 8:12 AM
> *To:* powershell@lists.myitforum.com
> *Subject:* [powershell] PowerShell.exe from cmd - WMI filter quotes
>
>
>
> 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 '%.%.%.%'" | select Name, PortName |
> ConvertTo-Csv -NoTypeInformation | out-file c:\temp\%Hostname%_printers.
> csv}"
>
>
>
>
>
> *Daniel Ratliff*
>
>
>
>
> The information transmitted is intended only for the person or entity to
> which it is addressed
> and may contain CONFIDENTIAL material. If you receive this
> material/information in error,
> please contact the sender and delete or destroy the material/information.
>
>
>
>
>
> The information transmitted is intended only for the person or entity to
> which it is addressed
> and may contain CONFIDENTIAL material. If you receive this
> material/information in error,
> please contact the sender and delete or destroy the material/information.
>
>

-- 
The information contained in this message is privileged, confidential, and 
protected from disclosure. If you are not the intended recipient, you are 
hereby notified that any review, printing, dissemination, distribution, 
copying or other use of this communication is strictly prohibited. If you 
have received this communication in error, please notify us immediately by 
replying to the message and deleting it from your computer.



Reply via email to