Hi There
I've been trying to get this powershell script to work it should produce a windows with a list of printers, It's using the powershell plus kit from the MSDN site (also in the win 7 resource kit).
If you look in the -DataContext section the commented out line will work, but the four lines below it don't. Can anyone see whats going wrong?Code:$DetectedErrorState="unknown","other","No Error","Low Paper","No Paper",` "Low Toner","No Toner","Door OPen","Jammed","Offline","Service Requested",` "output Bin Full" $PrinterStatus="Other","Unknown","Idle","Printing","Warming Up","Stopped Printing","Offiline" #function test{ # $class = "win32_printer" # $printers = Get-WmiObject -Class $Class -ComputerName "<COMPUTERNAME>" -Credential <DOMAIN>\<USERNAME> # foreach($p in $printers){ # output $p.Name, $DetectedErrorState[$p.DetectedErrorState], $PrinterStatus[$p.PrinterStatus] # } #} New-ListView -Width 350 -Height 350 -DataBinding @{ ItemsSource = New-Binding -IsAsync -UpdateSourceTrigger PropertyChanged -Path Output } -View { New-GridView -AllowsColumnReorder -Columns { New-GridViewColumn "Name" } } -DataContext { Get-PowerShellDataSource -Script { #Get-Process | ForEach-Object { $_ ; Start-Sleep -Milliseconds 25 } Get-WmiObject -Class $Class -ComputerName "<COMPUTERNAME" -Credential <DOMAIN>\<USERNAME> |` ForEach-Object { $_.Name } } } -On_Loaded { Register-PowerShellCommand -Run -In "0:0:15" -ScriptBlock { $window.Content.DataContext.Script = $window.Content.DataContext.Script } } -asjob
Thanks
.Adam



LinkBack URL
About LinkBacks
Reply With Quote

