powershell pipeline
powershell pipeline
Property
Collection
@{
n='VirtualMemory';
e={ $PSItem.VM }
} Semicolon
Expression Expression
key script block
Creating calculated properties
Get-Volume |
Select-Object –Property DriveLetter,
@{
n='Size(GB)';
e={'{0:N2}' -f ($PSItem.Size / 1GB)}
},
@{
n='FreeSpace(GB)';
e={'{0:N2}' -f ($PSItem.SizeRemaining / 1GB)}
}
Demonstration: Creating calculated
properties
Comparison operators
Basic filtering syntax
Advanced filtering syntax
Demonstration: Filtering
• Optimizing filtering performance
Comparison operators
Get-Service |
Where Status –eq Running
Get-Process |
Where CPU –gt 20
Basic filtering syntax
Purpose of enumeration
Basic enumeration syntax
Demonstration: Basic enumeration
Advanced enumeration syntax
• Demonstration: Advanced enumeration
Purpose of enumeration
Limitations:
• Can access only a single member (method
or property) of the objects that were piped
into the command
• Cannot:
• Run commands or code
• Evaluate expressions
• Make logical decisions
Demonstration: Basic enumeration
Logon Information
Virtual machines: 10961C-LON-DC1
10961C-LON-CL1
User name: Adatum\
Administrator
Password: Pa55w.rd
Estimated Time: 30 minutes
Lab Scenario
• ConvertTo-CliXml
• Export-CliXml
• Portable data format
• Multivalue properties become individual
entries
Converting output to JSON
• The command is
• ConvertTo-JSON
Logon Information
Virtual machines: 10961C-LON-DC1
10961C-LON-CL1
User name: Adatum\
Administrator
Password: Pa55w.rd
Estimated Time: 30 minutes
Lab Scenario
Review Question
Real-world Issues and Scenarios
Best Practice
• Common Issues and Troubleshooting Tips