Avoiding output message through [void]
- From: "DontBotherMeWithSpam" <DontBotherMeWithSpam@xxxxxxxxx>
- Date: 26 Jan 2006 15:49:07 -0800
I have create a simple function that lists accessible printers on my
current machine like the following.
============================================================
MSH>function get-printers {
>> [void]([reflection.assembly]::LoadWithPartialName("System.Drawing"))
>> [System.Drawing.Printing.PrinterSettings]::InstalledPrinters}
>>
MSH>get-printers
Microsoft Office Document Image Writer
HP LaserJet 8150 PCL 5e(관리국)
HP LaserJet 5000 Series PCL 5e(편집부)
HP LaserJet 5000 Series PCL 5e(Design)
HP LaserJet 4100 PCL 5e(특집부)
HP LaserJet 4100 PCL 5e(사회부)
HP LaserJet 4100 PCL 5e(광고 업무부)
HP LaserJet 4100 PCL 5e(경제부)
HP LaserJet 2430 PCL 5e(전산실)
HP LaserJet 2300 Series PCL 6(Flushing)
HP LaserJet 2300 Series PCL 5e(사업국)
HP Color LaserJet 5500 PCL6(Color)
Adobe PDF
MSH>get-printers
GAC Version Location
--- ------- --------
True v2.0.50727
C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\Syst....
Microsoft Office Document Image Writer
HP LaserJet 8150 PCL 5e(관리국)
HP LaserJet 5000 Series PCL 5e(편집부)
HP LaserJet 5000 Series PCL 5e(Design)
HP LaserJet 4100 PCL 5e(특집부)
HP LaserJet 4100 PCL 5e(사회부)
HP LaserJet 4100 PCL 5e(광고 업무부)
HP LaserJet 4100 PCL 5e(경제부)
HP LaserJet 2430 PCL 5e(전산실)
HP LaserJet 2300 Series PCL 6(Flushing)
HP LaserJet 2300 Series PCL 5e(사업국)
HP Color LaserJet 5500 PCL6(Color)
Adobe PDF
============================================================
On the first run, I get the list of printers without names.
But on the second time, i get the returned message of
"LoadWithPartialName" function.
So i have added "out-null" like the following
[void]([reflection.assembly]::LoadWithPartialName("System.Drawing")) |
out-null
Now, when everytime i run "get-printers", only printer names are
displayed.
My question being that, why was I getting the output for
"LoadWithPartialName" the second time I ran "get-printers" although in
the first time i wasn't getting it?
My main question is, how could i avoid running "LoadWithPartialName"
everytime I run the command?(I would like to know if a certain assembly
is loaded onto MSH or not)
.
- Follow-Ups:
- Re: Avoiding output message through [void]
- From: Keith Hill [MVP]
- Re: Avoiding output message through [void]
- Prev by Date: Re: Using copy command to a zipped folder
- Next by Date: Re: Avoiding output message through [void]
- Previous by thread: Re: Using copy command to a zipped folder
- Next by thread: Re: Avoiding output message through [void]
- Index(es):
Relevant Pages
|