 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to exclude the RunSpaceID property from the Invoke-Command output in PowerShell?
When we write Invoke-Command in PowerShell, sometimes we get the RunSpaceID property in PowerShell. This is because we use Select-Object (alias: Select) command inside the scriptblock. For example,
Example
Invoke-Command -ComputerName LabMachine2k12 -ScriptBlock{Get-Process PowerShell | Select Name, CPU, WorkingSet}  Output
Name : powershell CPU : 9.1572587 WorkingSet : 127700992 PSComputerName : LabMachine2k12 RunspaceId : c690f205-06d4-4cc4-be29-5302725eadf1
To avoid getting the RunSpaceID property in the output, use the Select command output the scriptblock. For example,
Example
Invoke-Command -ComputerName LabMachine2k12 -ScriptBlock{Get-Process PowerShell} | Select Name, CPU, WorkingSet  Output
Name CPU WorkingSet ---- --- ---------- powershell 9.1572587 127700992
Advertisements
 