0

I'm having trouble trying to query the items that are in Devices and Printers. The long run goal is to delete everything located in 'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices' except the devices located in Devices and Printers.

Unless there is another way to do this, I just need an array of the items in "Devices and Printers".

1 Answers1

0

You can discover commands with Get-Command or gcm.

This should get you going...

C:\WINDOWS\system32> gcm *printer*

CommandType     Name                                               Version    Source                                                                                     
-----------     ----                                               -------    ------                                                                                     
Function        Add-Printer                                        1.1        PrintManagement                                                                            
Function        Add-PrinterDriver                                  1.1        PrintManagement                                                                            
Function        Add-PrinterPort                                    1.1        PrintManagement                                                                            
Function        Get-Printer                                        1.1        PrintManagement                                                                            
Function        Get-PrinterDriver                                  1.1        PrintManagement                                                                            
Function        Get-PrinterPort                                    1.1        PrintManagement                                                                            
Function        Get-PrinterProperty                                1.1        PrintManagement                                                                            
Function        Read-PrinterNfcTag                                 1.1        PrintManagement                                                                            
Function        Remove-Printer                                     1.1        PrintManagement                                                                            
Function        Remove-PrinterDriver                               1.1        PrintManagement                                                                            
Function        Remove-PrinterPort                                 1.1        PrintManagement                                                                            
Function        Rename-Printer                                     1.1        PrintManagement                                                                            
Function        Set-Printer                                        1.1        PrintManagement                                                                            
Function        Set-PrinterProperty                                1.1        PrintManagement                                                                            
Function        Write-PrinterNfcTag                                1.1        PrintManagement                                                                            
Cmdlet          Out-Printer                                        3.1.0.0    Microsoft.PowerShell.Utility                                                               



C:\WINDOWS\system32> Get-Printer

Name                           ComputerName    Type         DriverName                PortName        Shared   Published  DeviceType     
----                           ------------    ----         ----------                --------        ------   ---------  ----------     
Send To OneNote 2016                           Local        Send to Microsoft OneN... nul:            False    False      Print          
Microsoft XPS Document Writer                  Local        Microsoft XPS Document... PORTPROMPT:     False    False      Print          
Microsoft Print to PDF                         Local        Microsoft Print To PDF    PORTPROMPT:     False    False      Print          
Fax                                            Local        Microsoft Shared Fax D... SHRFAX:         False    False      Print          
...
...
Kory Gill
  • 6,993
  • 1
  • 25
  • 33
  • Thanks @kory-gill ! That will definitely help in the future. However, I'm asking about getting the Name field into an array. For instance the variable $Devices will spit out only 'Send To OneNote 2016, Microsoft XPS Document Writer, etc'. – Devon Fisher Dec 17 '18 at 16:31
  • `Get-Printer | Select Name` will do this. – Kory Gill Dec 17 '18 at 18:07