Search code examples
stringpowershellcut

Powershell Sting Manipulation


I need to get few object from the output in a particular format mention after the output. Below is my output:

CompanyId        : 5d120af63e34a656bb6xxxxx
MachineId        : 5db2a769a43b9c68875xxxxx
UserId           : 5d120ac73e34a656bb6xxxxx
OwnerId          : 5d120ac73e34a656bb6xxxxx
Version          : 1.0.7
InstallationType : Regular
HttpsProxy       :
Socks5Proxy      :
NodeId           : A32BDF0D57F72509B2F7D208A106D2F92AC469AAD5BA8630C8198Dxxxxxxxxxx
Environment      : try
PSPath           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Apptinuum\SupportBOT
PSParentPath     : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Apptinuum
PSChildName      : SupportBOT
PSDrive          : HKLM
PSProvider       : Microsoft.PowerShell.Core\Registry

This is my output I want to manipulate object in following format:

CompanyId/MachineId/NodeId

only:

5d120af63e34a656bb6xxxxx/5db2a769a43b9c68875xxxxx/A32BDF0D57F72509B2F7D208A106D2F92AC469AAD5BA8630C8198Dxxxxxxxxxx

How can I get object like this using Powershell?


Solution

  • try use -f (-format):

    "{0}/{1}/{2}" -f $yourobject.CompanyId , $yourobject.MachineId , $yourobject.NodeId