Sounds good, I’ll give it a try. Thanks!
From: [email protected] [mailto:[email protected]] On Behalf Of Sherry Kissinger Sent: Wednesday, June 8, 2016 2:05 PM To: [email protected] Subject: Re: [mssms] More PowerShell help, please "I deploy it as a package that runs only when a user is logged on." So... you are doing that; "only when a user logged on", but with SYSTEM rights, correct? not "with user rights" ? You likely need to split up the script into two scripts. and using "run another program first". (using old traditional package/program logic). Program #1 you can run whether or not a user is logged in with system rights. and it's the 1st half. Program #2 is the second part, only when user logged in , with user rights. You make #2 "run another program first" of program #1, but you really only need to have it run once. I suspect the problem is that because you are running as "system" (despite a user being logged in at the time), it's recording the network printers for SYSTEM -- who doesn't have any network printers so there's nothing to say. Just like has to be done if you were using this old way, using old and boring vbscripts instead of cool new POSH scripts: http://www.mnscug.org/blogs/sherry-kissinger/316-configmgr-inventory-per-user-network-printer-mapped-information-datashift-replacement On Wed, Jun 8, 2016 at 2:44 PM, Murray, Mike <[email protected] <mailto:[email protected]> > wrote: I like the idea. Tried that, still same issue. First part of script works, second does not. :/ From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[email protected]> ] On Behalf Of Todd Hemsell Sent: Wednesday, June 8, 2016 11:44 AM To: [email protected] <mailto:[email protected]> Subject: Re: [mssms] More PowerShell help, please run it as a DCM rule as user with admin permissions. On Wed, Jun 8, 2016 at 1:30 PM, Murray, Mike <[email protected] <mailto:[email protected]> > wrote: I’m still trying to inventory network printers on computers. The script below is a combination of the two scripts mentioned here: https://gallery.technet.microsoft.com/SCCM-2012-NETWORK-PRINTER-776b59b4 I deploy it as a package that runs only when a user is logged on. It runs, but only does the first part of the script. It creates a new registry entry under HKLM\SOFTWARE\Wow6432Node called SCCMINVENTORY, and another under that called NETWORKPRINTERS. But the printers do not enumerate. If I run the script locally, they do. Any ideas why? #Configure Registry if (!(Test-Path HKLM:\SOFTWARE\SCCMINVENTORY)) {new-item HKLM:\SOFTWARE\SCCMINVENTORY -ErrorAction SilentlyContinue} $perm = get-acl HKLM:\SOFTWARE\SCCMINVENTORY -ErrorAction SilentlyContinue $rule = New-Object System.Security.AccessControl.RegistryAccessRule("Authenticated Users","FullControl", "ContainerInherit, ObjectInherit", "InheritOnly", "Allow") -ErrorAction SilentlyContinue $perm.SetAccessRule($rule) Set-Acl -Path HKLM:\SOFTWARE\SCCMINVENTORY $perm -ErrorAction SilentlyContinue if (!(Test-Path HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS)) {new-item HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS -ErrorAction SilentlyContinue} #Enumerate Printers $printers = Get-WMIObject -class Win32_Printer -ErrorAction SilentlyContinue|select-Object -Property ServerName,ShareName,Location,DriverName,PrintProcessor,PortName,Local |Where-Object {$_.Local -ne $true}-ErrorAction SilentlyContinue ForEach($printer in $printers){ $PServerName= $printer.ServerName -replace ('\\','') $PShareName = $printer.ShareName $PLocation = $printer.Location $PDriverName = $printer.DriverName $PPrintProcessor = $printer.PrintProcessor $PPortName = $printer.PortName if ((Test-Path HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS)) { if ((Test-Path "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName")) { Remove-item "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -Force -ErrorAction SilentlyContinue } New-item "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -ErrorAction SilentlyContinue New-ItemProperty "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -Name "PrintServer" -Value $PServerName -PropertyType "String" -ErrorAction SilentlyContinue New-ItemProperty "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -Name "PrinterQueue" -Value $PShareName -PropertyType "String" -ErrorAction SilentlyContinue New-ItemProperty "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -Name "PrinterLocation" -Value $PLocation -PropertyType "String" -ErrorAction SilentlyContinue New-ItemProperty "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -Name "PrinterDriver" -Value $PDriverName -PropertyType "String" -ErrorAction SilentlyContinue New-ItemProperty "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -Name "PrintProcessor" -Value $PPrintProcessor -PropertyType "String" -ErrorAction SilentlyContinue New-ItemProperty "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -Name "PrinterPortName" -Value $PPortName -PropertyType "String" -ErrorAction SilentlyContinue New-ItemProperty "HKLM:\SOFTWARE\SCCMINVENTORY\NETWORKPRINTERS\$PShareName on $PServerName" -Name "DateInventoried" -Value $(get-date) -PropertyType "String" -ErrorAction SilentlyContinue } } Best Regards, Mike Murray Desktop Management Coordinator - IT Support Services California State University, Chico 530.898.4357 <tel:530.898.4357> [email protected] <mailto:[email protected]> Remember, Chico State will NEVER ask you for your password via email! For more information about recognizing phishing scam emails go to: <http://www.csuchico.edu/isec/basics/spam-and-phishing.shtml> http://www.csuchico.edu/isec/basics/spam-and-phishing.shtml -- Thank you, Sherry Kissinger My Parameters: Standardize. Simplify. Automate Blogs: http://www.mofmaster.com, http://mnscug.org/blogs/sherry-kissinger, http://www.smguru.org
smime.p7s
Description: S/MIME cryptographic signature

