$all.Properties | ForEach-Object { [PSCustomObject]@{ # attention: property names on right side are case-sensitive! Name = $_.name[0] DN = $_.distinguishedname[0] } } } }
# make sure you specify a valid distinguishedname for a user below Get-NestedGroupMember-distinguishedName'CN=UserName,DC=powershell,DC=local'
# https://github.com/iainbrighton/PScribo # help about_document
# create a folder to store generated documents $OutPath = "c:\temp\out" $exists = Test-Path-Path$OutPath if (!$exists) { $null = New-Item-Path$OutPath-ItemType Directory -Force }
# generate document Document 'BIOS' { # get an object with rich information $info = Get-WmiObject-Class Win32_BIOS
# find out the property names that have actual information $properties = $info | Get-Member-MemberType *property | Select-Object-ExpandProperty Name | Where-Object {
$info.$_-ne$null-and$info.$_-ne''
} | Sort-Object
# turn each property into a separate object $infos = $properties | ForEach-Object { [PSCustomObject]@{ Name = $_ Value = $info.$_ }
}
Paragraph -Style Heading1 "BIOS Information"
# generate a table with one line per property $infos | # select the properties to display, and the header texts to use Table -Columns Name,Value -Headers'Item','Content'-Width0
# get the service data to use: # generate the service information to use # (requires PowerShell 5 because prior to PowerShell 5, Get-Service does not supply # StartType - alternative: use Get-WmiObject -Class Win32_Service, and adjust # property names)
# IMPORTANT: run this information through Select-Object to get a cloned copy # of the original objects so that style information can be appended $services = Get-Service | Select-Object-Property DisplayName, Status, StartType | Sort-Object-Property DisplayName
# define style to use for highlighting Style -Name HighlightedService -Color Red -BackgroundColor Yellow -Bold
# apply a different format to cell "Status" for all objects where # status is "Stopped" and StartType is "Automatic" $services | Where { $_.Status -eq'Stopped'-and$_.StartType -eq'Automatic'} | Set-Style-Property Status -Style HighlightedService
# https://github.com/iainbrighton/PScribo # help about_document
# create a folder to store generated documents $OutPath = "c:\temp\out" $exists = Test-Path-Path$OutPath if (!$exists) { $null = New-Item-Path$OutPath-ItemType Directory -Force }
# generate document Document 'ServiceReport' { # generate the service information to use # (requires PowerShell 5 because prior to PowerShell 5, Get-Service does not supply # StartType - alternative: use Get-WmiObject -Class Win32_Service, and adjust # property names) $services = Get-Service | Select-Object-Property DisplayName, Status, StartType
# generate a table with one line per service $services | # select the properties to display, and the header texts to use Table -Columns DisplayName, Status, StartType -Headers'Service Name','Current State','Startup Type'-Width0
# https://github.com/iainbrighton/PScribo # help about_document
# create a folder to store generated documents $OutPath = "c:\temp\out" $exists = Test-Path-Path$OutPath if (!$exists) { $null = New-Item-Path$OutPath-ItemType Directory -Force }
# generate document Document 'ADUser' { # get 40 AD user to illustrate $user = Get-ADUser-Filter * -ResultSetSize40-Properties mail | Select-Object-Property Name, mail, SID
Paragraph -Style Heading1 "AD User Liste"
# generate a table with one line per user $user | # select the properties to display, and the header texts to use Table -Columns Name, mail, SID -Headers'Employee','Email','SID'-Width0
# https://github.com/iainbrighton/PScribo # help about_document
# create a folder to store generated documents $OutPath = "c:\temp\out" $exists = Test-Path-Path$OutPath if (!$exists) { $null = New-Item-Path$OutPath-ItemType Directory -Force }
# generate document Document 'ServiceReport' { # generate the service information to use # (requires PowerShell 5 because prior to PowerShell 5, Get-Service does not supply # StartType - alternative: use Get-WmiObject -Class Win32_Service, and adjust # property names) $services = Get-Service | Select-Object-Property DisplayName, Status, StartType
# generate a table with one line per service $services | # select the properties to display, and the header texts to use Table -Columns DisplayName, Status, StartType -Headers'Service Name','Current State','Startup Type'-Width0