Skip to main content
deleted 1365 characters in body
Source Link
postanote
  • 4.9k
  • 2
  • 8
  • 7
# Get specifics for a module, cmdlet, or function
(Get-Command -Name).Parameters
(Get-Command -Name Get-Printer).Parameters.Keys
# Results
<#
Name
ComputerName
Full
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-Printer -Examples
Get-help -Name Get-Printer -Full
Get-help -Name Get-Printer -Online


# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-PrintConfiguration).Parameters
(Get-Command -Name Get-PrintConfiguration).Parameters.Keys
# Results
<#
ComputerName
PrinterName
PrinterObject
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-PrintConfiguration -Examples
Get-help -Name Get-PrintConfiguration -Full
Get-help -Name Get-PrintConfiguration -Online

Use the help file to know what is/is not available before you begin

# Get specifics for a module, cmdlet, or function
(Get-Command -Name).Parameters
(Get-Command -Name Get-Printer).Parameters.Keys
# Results
<#
Name
ComputerName
Full
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-Printer -Examples
Get-help -Name Get-Printer -Full
Get-help -Name Get-Printer -Online
 

# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-PrintConfiguration).Parameters
(Get-Command -Name Get-PrintConfiguration).Parameters.Keys
# Results
<#
ComputerName
PrinterName
PrinterObject
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-PrintConfiguration -Examples
Get-help -Name Get-PrintConfiguration -Full
Get-help -Name Get-PrintConfiguration -Online


# Get all data about one printer
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property '*'
# Results
<#
RenderingMode                : 
PrinterStatus                : Normal
Type                         : Local
DeviceType                   : Print
Caption                      : 
Description                  : 
ElementName                  : 
InstanceID                   : 
CommunicationStatus          : 
DetailedStatus               : 
HealthState                  : 
InstallDate                  : 
Name                         : OneNote for Windows 10
OperatingStatus              : 
OperationalStatus            : 
PrimaryStatus                : 
Status                       : 
StatusDescriptions           : 
BranchOfficeOfflineLogSizeMB : 
Comment                      : 
ComputerName                 : 
Datatype                     : RAW
DefaultJobPriority           : 0
DisableBranchOfficeLogging   : 
DriverName                   : Microsoft Software Printer Driver
JobCount                     : 0
KeepPrintedJobs              : False
Location                     : 
PermissionSDDL               : 
PortName                     : Microsoft.Office.OneNote_1600...
PrintProcessor               : winprint
Priority                     : 1
Published                    : False
SeparatorPageFile            : 
Shared                       : False
ShareName                    : 
StartTime                    : 0
UntilTime                    : 0
WorkflowPolicy               : 
PSComputerName               : 
CimClass                     : ROOT/StandardCimv2:MSFT_Printer
CimInstanceProperties        : {Caption...
CimSystemProperties          : Microsoft.Management.Infrastructure.CimSystemProperties
#>


Get-Printer | 
Select-Object -First 1 | 
Foreach {
    Get-PrintConfiguration -PrinterName $PSItem.name | 
    Select-Object -Property '*'
}
# Results
<#
DuplexingMode         : OneSided
PaperSize             : Letter
Collate               : True
Color                 : True
ComputerName          : 
PrintCapabilitiesXML  : <?xml version="1.0"?>
                        <...
                    
PrinterName           : OneNote for Windows 10
PrintTicketXML        : <?xml version="1.0"?>
                        ...
                    
PSComputerName        : 
CimClass              : ROOT/StandardCimv2:MSFT_PrinterConfiguration
CimInstanceProperties : {Collate, Color, ComputerName, DuplexingMode, PaperSize, PrintCapabilitiesXML, PrinterName, PrintTicketXML}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties
#>
# Get specifics for a module, cmdlet, or function
(Get-Command -Name).Parameters
(Get-Command -Name Get-Printer).Parameters.Keys
# Results
<#
Name
ComputerName
Full
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-Printer -Examples
Get-help -Name Get-Printer -Full
Get-help -Name Get-Printer -Online


# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-PrintConfiguration).Parameters
(Get-Command -Name Get-PrintConfiguration).Parameters.Keys
# Results
<#
ComputerName
PrinterName
PrinterObject
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-PrintConfiguration -Examples
Get-help -Name Get-PrintConfiguration -Full
Get-help -Name Get-PrintConfiguration -Online

Use the help file to know what is/is not available before you begin

# Get specifics for a module, cmdlet, or function
(Get-Command -Name).Parameters
(Get-Command -Name Get-Printer).Parameters.Keys
# Results
<#
Name
ComputerName
Full
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-Printer -Examples
Get-help -Name Get-Printer -Full
Get-help -Name Get-Printer -Online
 

# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-PrintConfiguration).Parameters
(Get-Command -Name Get-PrintConfiguration).Parameters.Keys
# Results
<#
ComputerName
PrinterName
PrinterObject
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-PrintConfiguration -Examples
Get-help -Name Get-PrintConfiguration -Full
Get-help -Name Get-PrintConfiguration -Online


# Get all data about one printer
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property '*'
# Results
<#
RenderingMode                : 
PrinterStatus                : Normal
Type                         : Local
DeviceType                   : Print
Caption                      : 
Description                  : 
ElementName                  : 
InstanceID                   : 
CommunicationStatus          : 
DetailedStatus               : 
HealthState                  : 
InstallDate                  : 
Name                         : OneNote for Windows 10
OperatingStatus              : 
OperationalStatus            : 
PrimaryStatus                : 
Status                       : 
StatusDescriptions           : 
BranchOfficeOfflineLogSizeMB : 
Comment                      : 
ComputerName                 : 
Datatype                     : RAW
DefaultJobPriority           : 0
DisableBranchOfficeLogging   : 
DriverName                   : Microsoft Software Printer Driver
JobCount                     : 0
KeepPrintedJobs              : False
Location                     : 
PermissionSDDL               : 
PortName                     : Microsoft.Office.OneNote_1600...
PrintProcessor               : winprint
Priority                     : 1
Published                    : False
SeparatorPageFile            : 
Shared                       : False
ShareName                    : 
StartTime                    : 0
UntilTime                    : 0
WorkflowPolicy               : 
PSComputerName               : 
CimClass                     : ROOT/StandardCimv2:MSFT_Printer
CimInstanceProperties        : {Caption...
CimSystemProperties          : Microsoft.Management.Infrastructure.CimSystemProperties
#>


Get-Printer | 
Select-Object -First 1 | 
Foreach {
    Get-PrintConfiguration -PrinterName $PSItem.name | 
    Select-Object -Property '*'
}
# Results
<#
DuplexingMode         : OneSided
PaperSize             : Letter
Collate               : True
Color                 : True
ComputerName          : 
PrintCapabilitiesXML  : <?xml version="1.0"?>
                        <...
                    
PrinterName           : OneNote for Windows 10
PrintTicketXML        : <?xml version="1.0"?>
                        ...
                    
PSComputerName        : 
CimClass              : ROOT/StandardCimv2:MSFT_PrinterConfiguration
CimInstanceProperties : {Collate, Color, ComputerName, DuplexingMode, PaperSize, PrintCapabilitiesXML, PrinterName, PrintTicketXML}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties
#>
# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-Printer).Parameters
(Get-Command -Name Get-Printer).Parameters.Keys
# Results
<#
Name
ComputerName
Full
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-Printer -Examples
Get-help -Name Get-Printer -Full
Get-help -Name Get-Printer -Online


(Get-Command -Name Get-PrintConfiguration).Parameters
(Get-Command -Name Get-PrintConfiguration).Parameters.Keys
# Results
<#
ComputerName
PrinterName
PrinterObject
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-PrintConfiguration -Examples
Get-help -Name Get-PrintConfiguration -Full
Get-help -Name Get-PrintConfiguration -Online


# Get all data about one printer
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property '*'
# Results
<#
RenderingMode                : 
PrinterStatus                : Normal
Type                         : Local
DeviceType                   : Print
Caption                      : 
Description                  : 
ElementName                  : 
InstanceID                   : 
CommunicationStatus          : 
DetailedStatus               : 
HealthState                  : 
InstallDate                  : 
Name                         : OneNote for Windows 10
OperatingStatus              : 
OperationalStatus            : 
PrimaryStatus                : 
Status                       : 
StatusDescriptions           : 
BranchOfficeOfflineLogSizeMB : 
Comment                      : 
ComputerName                 : 
Datatype                     : RAW
DefaultJobPriority           : 0
DisableBranchOfficeLogging   : 
DriverName                   : Microsoft Software Printer Driver
JobCount                     : 0
KeepPrintedJobs              : False
Location                     : 
PermissionSDDL               : 
PortName                     : Microsoft.Office.OneNote_1600...
PrintProcessor               : winprint
Priority                     : 1
Published                    : False
SeparatorPageFile            : 
Shared                       : False
ShareName                    : 
StartTime                    : 0
UntilTime                    : 0
WorkflowPolicy               : 
PSComputerName               : 
CimClass                     : ROOT/StandardCimv2:MSFT_Printer
CimInstanceProperties        : {Caption...
CimSystemProperties          : Microsoft.Management.Infrastructure.CimSystemProperties
#>


Get-Printer | 
Select-Object -First 1 | 
Foreach {
    Get-PrintConfiguration -PrinterName $PSItem.name | 
    Select-Object -Property '*'
}
# Results
<#
DuplexingMode         : OneSided
PaperSize             : Letter
Collate               : True
Color                 : True
ComputerName          : 
PrintCapabilitiesXML  : <?xml version="1.0"?>
                        <...
                    
PrinterName           : OneNote for Windows 10
PrintTicketXML        : <?xml version="1.0"?>
                        ...
                    
PSComputerName        : 
CimClass              : ROOT/StandardCimv2:MSFT_PrinterConfiguration
CimInstanceProperties : {Collate, Color, ComputerName, DuplexingMode, PaperSize, PrintCapabilitiesXML, PrinterName, PrintTicketXML}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties
#>
added 624 characters in body
Source Link
postanote
  • 4.9k
  • 2
  • 8
  • 7

... is wrong and can be simplified to this...

# Get specifics for a module, cmdlet, or function
(Get-Command -Name).Parameters
(Get-Command -Name Get-Printer).Parameters.Keys
# Results
<#
Name
ComputerName
Full
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-Printer -Examples
Get-help -Name Get-Printer -Full
Get-help -Name Get-Printer -Online


# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-PrintConfiguration).Parameters
(Get-Command -Name Get-PrintConfiguration).Parameters.Keys
# Results
<#
ComputerName
PrinterName
PrinterObject
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-PrintConfiguration -Examples
Get-help -Name Get-PrintConfiguration -Full
Get-help -Name Get-PrintConfiguration -Online


# Get all data about one printer
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property '*'
# Results
<#
RenderingMode                : 
PrinterStatus                : Normal
Type                         : Local
DeviceType                   : Print
Caption                      : 
Description                  : 
ElementName                  : 
InstanceID                   : 
CommunicationStatus          : 
DetailedStatus               : 
HealthState                  : 
InstallDate                  : 
Name                         : OneNote for Windows 10
OperatingStatus              : 
OperationalStatus            : 
PrimaryStatus                : 
Status                       : 
StatusDescriptions           : 
BranchOfficeOfflineLogSizeMB : 
Comment                      : 
ComputerName                 : 
Datatype                     : RAW
DefaultJobPriority           : 0
DisableBranchOfficeLogging   : 
DriverName                   : Microsoft Software Printer Driver
JobCount                     : 0
KeepPrintedJobs              : False
Location                     : 
PermissionSDDL               : 
PortName                     : Microsoft.Office.OneNote_1600...
PrintProcessor               : winprint
Priority                     : 1
Published                    : False
SeparatorPageFile            : 
Shared                       : False
ShareName                    : 
StartTime                    : 0
UntilTime                    : 0
WorkflowPolicy               : 
PSComputerName               : 
CimClass                     : ROOT/StandardCimv2:MSFT_Printer
CimInstanceProperties        : {Caption...
CimSystemProperties          : Microsoft.Management.Infrastructure.CimSystemProperties
#>


Get-Printer |  
Select-Object -First 1 | 
Foreach {
    Get-PrintConfiguration -PrinterName $PSItem.name | 
    Select-Object -Property '*'
}
# Results
<#
DuplexingMode         : OneSided
PaperSize             : Letter
Collate               : True
Color                 : True
ComputerName          : 
PrintCapabilitiesXML  : <?xml version="1.0"?>
                        <...
                    
PrinterName           : OneNote for Windows 10
PrintTicketXML        : <?xml version="1.0"?>
                        ...
                    
PSComputerName        : 
CimClass              : ROOT/StandardCimv2:MSFT_PrinterConfiguration
CimInstanceProperties : {Collate, Color, ComputerName, DuplexingMode, PaperSize, PrintCapabilitiesXML, PrinterName, PrintTicketXML}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties
#>
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property Name, DriverName, PortName, Comment, Location, 
@{
    Name       = 'Color'
    Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).Color}
},
@{
    Name       = 'DuplexingMode '
    Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).DuplexingMode }
}
# Results
<#
Name           : OneNote for Windows 10
DriverName     : Microsoft Software Printer Driver
PortName       : Microsoft.Office.OneNote_16001.13801.20202.0_x64__8wekyb3d8bbwe_microsoft.onenoteim_S-1-5-21-3258886415-1034932420-179337933-1002
Comment        : 
Location       : 
Color          : True
DuplexingMode  : OneSided
#>
Select-Object -First 1 | 

... no ForLoop required for your use case.

The above could also be written this way if you want to compress the number of lines.

Get-Printer | Select-Object -Property Name, DriverName, PortName, Comment, Location, 
@{Name = 'Color';Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).Color}},
@{Name = 'DuplexingMode';Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).DuplexingMode}}
# Results
<#
Name          : OneNote for Windows 10
DriverName    : Microsoft Software Printer Driver
PortName      : Microsoft.Office.OneNote_16001.13801.20202.0_x64__8wekyb3d8bbwe_microsoft.onenoteim_S-1-5-21-3258886415-1034932420-179337933-1002
Comment       : 
Location      : 
Color         : True
DuplexingMode : OneSided

...

Name          : Microsoft XPS Document Writer
DriverName    : Microsoft XPS Document Writer v4
PortName      : PORTPROMPT:
Comment       : 
Location      : 
Color         : True
DuplexingMode : OneSided

Name          : Microsoft Print to PDF
DriverName    : Microsoft Print To PDF
PortName      : PORTPROMPT:
Comment       : 
Location      : 
Color         : True
DuplexingMode : OneSided

Name          : Fax
DriverName    : Microsoft Shared Fax Driver
PortName      : SHRFAX:
Comment       : 
Location      : 
Color         : False
DuplexingMode : OneSided

...
#>

Yet, I just find that harder to read. But that is just me. The use of natural line breaks, like '|', ';', ::', comparison operators and others just allow for making things more humanly readable.

... is wrong and can be simplified to this...

# Get specifics for a module, cmdlet, or function
(Get-Command -Name).Parameters
(Get-Command -Name Get-Printer).Parameters.Keys
# Results
<#
Name
ComputerName
Full
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-Printer -Examples
Get-help -Name Get-Printer -Full
Get-help -Name Get-Printer -Online


# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-PrintConfiguration).Parameters
(Get-Command -Name Get-PrintConfiguration).Parameters.Keys
# Results
<#
ComputerName
PrinterName
PrinterObject
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-PrintConfiguration -Examples
Get-help -Name Get-PrintConfiguration -Full
Get-help -Name Get-PrintConfiguration -Online


# Get all data about one printer
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property '*'
# Results
<#
RenderingMode                : 
PrinterStatus                : Normal
Type                         : Local
DeviceType                   : Print
Caption                      : 
Description                  : 
ElementName                  : 
InstanceID                   : 
CommunicationStatus          : 
DetailedStatus               : 
HealthState                  : 
InstallDate                  : 
Name                         : OneNote for Windows 10
OperatingStatus              : 
OperationalStatus            : 
PrimaryStatus                : 
Status                       : 
StatusDescriptions           : 
BranchOfficeOfflineLogSizeMB : 
Comment                      : 
ComputerName                 : 
Datatype                     : RAW
DefaultJobPriority           : 0
DisableBranchOfficeLogging   : 
DriverName                   : Microsoft Software Printer Driver
JobCount                     : 0
KeepPrintedJobs              : False
Location                     : 
PermissionSDDL               : 
PortName                     : Microsoft.Office.OneNote_1600...
PrintProcessor               : winprint
Priority                     : 1
Published                    : False
SeparatorPageFile            : 
Shared                       : False
ShareName                    : 
StartTime                    : 0
UntilTime                    : 0
WorkflowPolicy               : 
PSComputerName               : 
CimClass                     : ROOT/StandardCimv2:MSFT_Printer
CimInstanceProperties        : {Caption...
CimSystemProperties          : Microsoft.Management.Infrastructure.CimSystemProperties
#>


Get-Printer | Select-Object -First 1 | 
Foreach {
    Get-PrintConfiguration -PrinterName $PSItem.name | 
    Select-Object -Property '*'
}
# Results
<#
DuplexingMode         : OneSided
PaperSize             : Letter
Collate               : True
Color                 : True
ComputerName          : 
PrintCapabilitiesXML  : <?xml version="1.0"?>
                        <...
                    
PrinterName           : OneNote for Windows 10
PrintTicketXML        : <?xml version="1.0"?>
                        ...
                    
PSComputerName        : 
CimClass              : ROOT/StandardCimv2:MSFT_PrinterConfiguration
CimInstanceProperties : {Collate, Color, ComputerName, DuplexingMode, PaperSize, PrintCapabilitiesXML, PrinterName, PrintTicketXML}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties
#>
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property Name, DriverName, PortName, Comment, Location, 
@{
    Name = 'Color'
    Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).Color}
},
@{
    Name = 'DuplexingMode '
    Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).DuplexingMode }
}
# Results
<#
Name           : OneNote for Windows 10
DriverName     : Microsoft Software Printer Driver
PortName       : Microsoft.Office.OneNote_16001.13801.20202.0_x64__8wekyb3d8bbwe_microsoft.onenoteim_S-1-5-21-3258886415-1034932420-179337933-1002
Comment        : 
Location       : 
Color          : True
DuplexingMode  : OneSided
#>
Select-Object -First 1 | 

... can be simplified to this...

# Get specifics for a module, cmdlet, or function
(Get-Command -Name).Parameters
(Get-Command -Name Get-Printer).Parameters.Keys
# Results
<#
Name
ComputerName
Full
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-Printer -Examples
Get-help -Name Get-Printer -Full
Get-help -Name Get-Printer -Online


# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-PrintConfiguration).Parameters
(Get-Command -Name Get-PrintConfiguration).Parameters.Keys
# Results
<#
ComputerName
PrinterName
PrinterObject
CimSession
ThrottleLimit
AsJob
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
#>
Get-help -Name Get-PrintConfiguration -Examples
Get-help -Name Get-PrintConfiguration -Full
Get-help -Name Get-PrintConfiguration -Online


# Get all data about one printer
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property '*'
# Results
<#
RenderingMode                : 
PrinterStatus                : Normal
Type                         : Local
DeviceType                   : Print
Caption                      : 
Description                  : 
ElementName                  : 
InstanceID                   : 
CommunicationStatus          : 
DetailedStatus               : 
HealthState                  : 
InstallDate                  : 
Name                         : OneNote for Windows 10
OperatingStatus              : 
OperationalStatus            : 
PrimaryStatus                : 
Status                       : 
StatusDescriptions           : 
BranchOfficeOfflineLogSizeMB : 
Comment                      : 
ComputerName                 : 
Datatype                     : RAW
DefaultJobPriority           : 0
DisableBranchOfficeLogging   : 
DriverName                   : Microsoft Software Printer Driver
JobCount                     : 0
KeepPrintedJobs              : False
Location                     : 
PermissionSDDL               : 
PortName                     : Microsoft.Office.OneNote_1600...
PrintProcessor               : winprint
Priority                     : 1
Published                    : False
SeparatorPageFile            : 
Shared                       : False
ShareName                    : 
StartTime                    : 0
UntilTime                    : 0
WorkflowPolicy               : 
PSComputerName               : 
CimClass                     : ROOT/StandardCimv2:MSFT_Printer
CimInstanceProperties        : {Caption...
CimSystemProperties          : Microsoft.Management.Infrastructure.CimSystemProperties
#>


Get-Printer |  
Select-Object -First 1 | 
Foreach {
    Get-PrintConfiguration -PrinterName $PSItem.name | 
    Select-Object -Property '*'
}
# Results
<#
DuplexingMode         : OneSided
PaperSize             : Letter
Collate               : True
Color                 : True
ComputerName          : 
PrintCapabilitiesXML  : <?xml version="1.0"?>
                        <...
                    
PrinterName           : OneNote for Windows 10
PrintTicketXML        : <?xml version="1.0"?>
                        ...
                    
PSComputerName        : 
CimClass              : ROOT/StandardCimv2:MSFT_PrinterConfiguration
CimInstanceProperties : {Collate, Color, ComputerName, DuplexingMode, PaperSize, PrintCapabilitiesXML, PrinterName, PrintTicketXML}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties
#>
Get-Printer | 
Select-Object -First 1 | 
Select-Object -Property Name, DriverName, PortName, Comment, Location, 
@{
    Name       = 'Color'
    Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).Color}
},
@{
    Name       = 'DuplexingMode '
    Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).DuplexingMode }
}
# Results
<#
Name           : OneNote for Windows 10
DriverName     : Microsoft Software Printer Driver
PortName       : Microsoft.Office.OneNote_16001.13801.20202.0_x64__8wekyb3d8bbwe_microsoft.onenoteim_S-1-5-21-3258886415-1034932420-179337933-1002
Comment        : 
Location       : 
Color          : True
DuplexingMode  : OneSided
#>
Select-Object -First 1 | 

... no ForLoop required for your use case.

The above could also be written this way if you want to compress the number of lines.

Get-Printer | Select-Object -Property Name, DriverName, PortName, Comment, Location, 
@{Name = 'Color';Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).Color}},
@{Name = 'DuplexingMode';Expression = {(Get-PrintConfiguration -PrinterName $PSItem.Name).DuplexingMode}}
# Results
<#
Name          : OneNote for Windows 10
DriverName    : Microsoft Software Printer Driver
PortName      : Microsoft.Office.OneNote_16001.13801.20202.0_x64__8wekyb3d8bbwe_microsoft.onenoteim_S-1-5-21-3258886415-1034932420-179337933-1002
Comment       : 
Location      : 
Color         : True
DuplexingMode : OneSided

...

Name          : Microsoft XPS Document Writer
DriverName    : Microsoft XPS Document Writer v4
PortName      : PORTPROMPT:
Comment       : 
Location      : 
Color         : True
DuplexingMode : OneSided

Name          : Microsoft Print to PDF
DriverName    : Microsoft Print To PDF
PortName      : PORTPROMPT:
Comment       : 
Location      : 
Color         : True
DuplexingMode : OneSided

Name          : Fax
DriverName    : Microsoft Shared Fax Driver
PortName      : SHRFAX:
Comment       : 
Location      : 
Color         : False
DuplexingMode : OneSided

...
#>

Yet, I just find that harder to read. But that is just me. The use of natural line breaks, like '|', ';', ::', comparison operators and others just allow for making things more humanly readable.

added 785 characters in body
Source Link
postanote
  • 4.9k
  • 2
  • 8
  • 7

You need to pintselect the stuff you want, then combine together using a hash-table or custom object. Now that is not day one/host one stuff, but again, many articles/blogs/videos, samp[lessamples/examples on combining cmdlet output is plentiful.

You need to pint the stuff you want, then combine together using hash-table or custom object. Now that is not day one/host one stuff, but again, many articles/blogs/videos, samp[les/examples on combining cmdlet output is plentiful.

You need to select the stuff you want, then combine together using a hash-table or custom object. Now that is not day one stuff, but again, many articles/blogs/videos, samples/examples on combining cmdlet output is plentiful.

added 785 characters in body
Source Link
postanote
  • 4.9k
  • 2
  • 8
  • 7
Loading
added 5826 characters in body
Source Link
postanote
  • 4.9k
  • 2
  • 8
  • 7
Loading
Source Link
postanote
  • 4.9k
  • 2
  • 8
  • 7
Loading