Jeroen Budding
Jeroen Budding

Reputation: 3

Powershell Replace column data

I have the following command:

 $WSUSClients = Get-WsusComputer | Select-Object FullDomainName, OSDescription, LastSyncResult, RequestedTargetGroupName
 $WSUSClients | ForEach-Object {$_.FullDomainName -replace ('.corp.com','')} | Set-Content 'C:\Script\WSUS Clients\WSUSclients.csv'

Last part it not correct I want to replace the .corp.com from the column FullDomainname and still leave the other columns but don't get this working.

Upvotes: 0

Views: 483

Answers (1)

restless1987
restless1987

Reputation: 1598

just use a custom column:

$prop = @{
  name = 'FullDomainName'
  Expression = {$_.FullDomainName.replace('.corp.com','')}
}
$WSUSClients = Get-WsusComputer | Select-Object $prop, OSDescription, LastSyncResult, RequestedTargetGroupName $WSUSClients | Set-Content 'C:\Script\WSUS Clients\WSUSclients.csv'

Upvotes: 1

Related Questions