![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How check local Queues in a If Hello I have problems with check local queues. I have a db with queues. 1. Check local system of. Is queue exist. when not create this part don't function. Where is the error? Do you have a idea? Thanks for you help Thanks Gregor #SQL Connection aufbauen $conn = new-object System.Data.SqlClient.SqlConnection $conn.ConnectionString = "server=hsb592as;database=PrintMgmt;integrated security=true" $cmd = new-object System.Data.SqlClient.SqlCommand("spCreateQueue", $conn) $cmd.CommandType = [System.Data.CommandType]'StoredProcedure' $cmd.Parameters.Add("@PrintServerName",$env:COMPUTERNAME) $cmd.Connection = $conn $adapter = new-object System.Data.SqlClient.SqlDataAdapter $adapter.SelectCommand = $cmd $ds = new-object System.Data.DataSet $adapter.Fill($ds) $conn.close() #DataTable erstellen $dt = new-object "System.Data.DataTable" "dtData" $dt = $ds.Tables[0] $dt | FOREACH-OBJECT { $PrintSRV = $_.PrintServer $PrintSRVShort = $_.PrintServerShort $QueueTemplate = $_.QueueTemplate $QueueName = $_.Printername+'_'+$_.QueueName $PrinterName = $_.PrinterName $PrinterPortDomain = '.bkw-fmb.ch' $PrinterPort = $_.PrinterName+'.bkw-fmb.ch' $UNCName = '\\'+$_.PrintServer+'\'+$_.QueueName $Url = 'http://'+$_.PrintServer+'/'+$_.QueueName $Location = $_.Location #$Description = 'Kommentar Feld' $FilterPPort = "Name = '$PrinterPort'" $FilterQueue = "Name = '$_.QueueName'" $RegFile = $_.QueueRegFile #Add PrinterPort $colItemPrinterPort = get-WmiObject -class "Win32_TCPIPPrinterPort" -namespace "root\CIMV2" -computername $env:COMPUTERNAME -Filter $FilterPPort | foreach {$_.name} If ($colItemPrinterPort -eq $PrinterPort) { write-Host = "Port exist" $PrinterPort } else { #Create PrinterPort cmd /c start /wait Cscript c:\Windows\System32\Prnport.vbs -a -s $env:COMPUTERNAME -r $PrinterPort -h $PrinterPort -me -y public -o raw -n 9100 write-Host = "Port created" $PrinterPort } 1. >>>>>>>>>>>>>>>>>>> $colItemQueue = get-WmiObject -class "Win32_Printer" -namespace "root\CIMV2" -computername $env:COMPUTERNAME -Filter $FilterQueue | foreach {$_.name} if ($colItemQueue -eq $QueueName) { Write-Host = "Queue "$QueueName" exist" } else { Write-Host = "Queue "$QueueName" create" .... } Quote: Quote: Quote: >>>>>>>>>>>>>>>>>>>>>>>> |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How check local Queues in a If Quote: > #Create PrinterPort > cmd /c start /wait Cscript c:\Windows\System32\Prnport.vbs -a -s > $env:COMPUTERNAME -r $PrinterPort -h $PrinterPort -me -y public -o raw > -n 9100 > write-Host = "Port created" $PrinterPort cmd /c start /wait "Cscript c:\Windows\System32\Prnport.vbs -a -s $env:COMPUTERNAME -r $PrinterPort -h $PrinterPort -me -y public -o raw -n 9100" The variables you are declaring are likely not being passed to the VBScript script. Also, it is not: write-host = "something" but instead write-host "something" Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How check local Queues in a If Hello Marco My problem is: $colItemQueue = get-WmiObject -class "Win32_Printer" -namespace "root\CIMV2" -computername $env:COMPUTERNAME -Filter $FilterQueue | foreach {$_.name} if ($colItemQueue -eq $QueueName) { Write-Host = "Queue "$QueueName" exist" } else { Write-Host = "Queue "$QueueName" create" .... } "Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message news:ehcpwjwbIHA.4712@xxxxxx Quote: > Quote: >> #Create PrinterPort >> cmd /c start /wait Cscript c:\Windows\System32\Prnport.vbs -a -s >> $env:COMPUTERNAME -r $PrinterPort -h $PrinterPort -me -y public -o raw -n >> 9100 >> write-Host = "Port created" $PrinterPort > If I follow, I would try doing this: > cmd /c start /wait "Cscript c:\Windows\System32\Prnport.vbs -a -s > $env:COMPUTERNAME -r $PrinterPort -h $PrinterPort -me -y public -o raw -n > 9100" > > The variables you are declaring are likely not being passed to the > VBScript script. > > Also, it is not: > write-host = "something" > but instead > write-host "something" > > Marco > > > -- > Microsoft MVP - Windows PowerShell > http://www.microsoft.com/mvp > > PowerGadgets MVP > http://www.powergadgets.com/mvp > > Blog: > http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How check local Queues in a If 1. for local computers -computername parameter is not needed 2. "root\CIMV2" is the default WMI namespace, you can remove it 3. You can't do Write-Host = "something", and there are also double quotes errors. Try this: $colItemQueue = get-WmiObject -class "Win32_Printer" -namespace -Filter $FilterQueue | where {$_.name -eq $QueueName} if ($colItemQueue){ Write-Host "Queue $QueueName exist" } else { Write-Host "Queue $QueueName create" .... } ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Hello Marco > > My problem is: > > $colItemQueue = get-WmiObject -class "Win32_Printer" -namespace > "root\CIMV2" -computername $env:COMPUTERNAME -Filter $FilterQueue | > foreach {$_.name} > > if ($colItemQueue -eq $QueueName) > { > Write-Host = "Queue "$QueueName" exist" > } > else > { > Write-Host = "Queue "$QueueName" create" > ... > } > "Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message > news:ehcpwjwbIHA.4712@xxxxxx > Quote: Quote: >>> #Create PrinterPort >>> cmd /c start /wait Cscript c:\Windows\System32\Prnport.vbs -a -s >>> $env:COMPUTERNAME -r $PrinterPort -h $PrinterPort -me -y public -o >>> raw -n >>> 9100 >>> write-Host = "Port created" $PrinterPort >> cmd /c start /wait "Cscript c:\Windows\System32\Prnport.vbs -a -s >> $env:COMPUTERNAME -r $PrinterPort -h $PrinterPort -me -y public -o >> raw -n >> 9100" >> The variables you are declaring are likely not being passed to the >> VBScript script. >> >> Also, it is not: >> write-host = "something" >> but instead >> write-host "something" >> Marco >> >> -- >> Microsoft MVP - Windows PowerShell >> http://www.microsoft.com/mvp >> PowerGadgets MVP >> http://www.powergadgets.com/mvp >> Blog: >> http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #5 (permalink) |
| | Re: How check local Queues in a If Gregor wrote: Quote: > Hello Marco > > My problem is: > > $colItemQueue = get-WmiObject -class "Win32_Printer" -namespace > "root\CIMV2" -computername $env:COMPUTERNAME -Filter $FilterQueue | > foreach {$_.name} > > if ($colItemQueue -eq $QueueName) > { > Write-Host = "Queue "$QueueName" exist" > } > else > { > Write-Host = "Queue "$QueueName" create" > ... > } $colItemQueue = get-WmiObject -class "Win32_Printer" -namespace "root\CIMV2" -computername $env:COMPUTERNAME -Filter $FilterQueue if ($colItemQueue -ne $null) { Write-Host = "Queue "$QueueName" exist" } else { Write-Host = "Queue "$QueueName" create" .... } |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Getting print queues | PowerShell | |||
| Add local machine users to local admin group via GPO | .NET General | |||
| error 0x80040707 dll functioncall crashed BRADDPRT. check local po | Vista General | |||
| Creating msmq queues, triggers and rules | PowerShell | |||
| Newbie: Nagios with nrpe_nt, check for diskspace; check services,returncode | PowerShell | |||