Hello there,
Give this a try, you can export it to CSV and import it back as objects:
$result = dsquery computer domainroot -name * -limit 0 | foreach {
repadmin /showattr $DCName $_ /atts:"WhenChanged,WhenCreated,OperatingSystem" /long
} | Out-String
$result.split([string[]]'DN:',[StringSplitOptions]::RemoveEmptyEntries) | Foreach-Object{
$attr = $_.Split("`r`n",[StringSplitOptions]::RemoveEmptyEntries)
New-Object -TypeName PSObject -Property @{
DN = $attr[0].Trim()
whenCreated = $attr[1].Trim() -replace '^1> whenCreated: '
whenChanged = $attr[2].Trim() -replace '^1> whenChanged: '
operatingSystem = $attr[3].Trim() -replace '^1> operatingSystem: '
}
}
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--
Need powershell script to send output (repadmin /replsum) in the mail body not as attachment.
Aditya
20
Reputation points
Need powershell script to send output (repadmin /replsum) in the mail body not as attachment. i tried some script to send they were working but output data not came as they showing in CMD. all data come in single line.
3 answers
Sort by: Most helpful
-
Limitless Technology 44,121 Reputation points
2023-04-17T13:49:49.24+00:00 -
MotoX80 32,911 Reputation points
2023-04-17T14:52:35.0333333+00:00 If your email is formatted as ".IsBodyHtml = $true", then you just need to format the output from repladm to add the line breaks. On way would be to enclose the output in <pre> tags, or append <br> tags to each line.
$out = repadmin /replsum $formattedout = "<pre>$out</pre>" # one way $formattedout = $out -join "<br>" # another way
-
Aditya 20 Reputation points
2023-04-24T04:51:04.2+00:00 I have founded the script which is works for me. $repadminOutput = repadmin /replsum | Out-String $body = @" $repadminOutput "@