help, i need to export this report to .CSV file<\/p>\n
$UserCredential = Get-Credential<\/p>\n
Install-Module -Name PSWindowsUpdate -Force
\nGet-Package -Name PSWindowsUpdate
\nSet-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
\nGet-WindowsUpdate -MicrosoftUpdate -Verbose
\nInstall-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot
\nwmic qfe list<\/p>\n
function Convert-WuaResultCodeToName
\n{
\nparam( [Parameter(Mandatory=$true)]
\n[int] $ResultCode
\n)
\n$Result = $ResultCode
\nswitch($ResultCode)
\n{
\n2
\n{
\n$Result = “Succeeded”
\n}
\n3
\n{
\n$Result = “Succeeded With Errors”
\n}
\n4
\n{
\n$Result = “Failed”
\n}
\n}
\nreturn $Result
\n}
\nfunction Get-WuaHistory
\n{<\/p>\n
$session = (New-Object -ComObject ‘Microsoft.Update.Session’)<\/p>\n
$history = $session.QueryHistory(“”,0,50) | ForEach-Object {
\n$Result = Convert-WuaResultCodeToName -ResultCode $_.ResultCode<\/p>\n
$_ | Add-Member -MemberType NoteProperty -Value $Result -Name Result Get-WuaHistory | Format-Table<\/p>\n Export-Csv >Export-Csv “c:\\users\\lesliecalvo\\Desktop\\WindowsUpdate.csv” -NoTypeInformation<\/p>\n cmd /c pause<\/p>","upvoteCount":5,"answerCount":12,"datePublished":"2021-12-21T15:03:44.000Z","author":{"@type":"Person","name":"lesliecalvo","url":"https://community.spiceworks.com/u/lesliecalvo"},"suggestedAnswer":[{"@type":"Answer","text":" help, i need to export this report to .CSV file<\/p>\n $UserCredential = Get-Credential<\/p>\n Install-Module -Name PSWindowsUpdate -Force function Convert-WuaResultCodeToName $session = (New-Object -ComObject ‘Microsoft.Update.Session’)<\/p>\n $history = $session.QueryHistory(“”,0,50) | ForEach-Object { $_ | Add-Member -MemberType NoteProperty -Value $Result -Name Result Get-WuaHistory | Format-Table<\/p>\n Export-Csv >Export-Csv “c:\\users\\lesliecalvo\\Desktop\\WindowsUpdate.csv” -NoTypeInformation<\/p>\n cmd /c pause<\/p>","upvoteCount":5,"datePublished":"2021-12-21T15:03:44.000Z","url":"https://community.spiceworks.com/t/help/820245/1","author":{"@type":"Person","name":"lesliecalvo","url":"https://community.spiceworks.com/u/lesliecalvo"}},{"@type":"Answer","text":" Please past your PowerShell content using insert code option </> so it formats correctly.<\/p>\n And if you want help, please try a meaningful topic - ‘help’ is too generic.<\/p>","upvoteCount":1,"datePublished":"2021-12-21T15:08:10.000Z","url":"https://community.spiceworks.com/t/help/820245/2","author":{"@type":"Person","name":"Rod-IT","url":"https://community.spiceworks.com/u/Rod-IT"}},{"@type":"Answer","text":" sorry is I am frustrated no but yes ur correct. can u help me pls, i will like to export it to a .csv file<\/p>","upvoteCount":0,"datePublished":"2021-12-21T15:15:01.000Z","url":"https://community.spiceworks.com/t/help/820245/3","author":{"@type":"Person","name":"lesliecalvo","url":"https://community.spiceworks.com/u/lesliecalvo"}},{"@type":"Answer","text":" You would want to pipe your variable out to Export-CSV.<\/p>\n For example, if your variable was $Result<\/p>\n Also there’s no need for the cmd /c pause. Just use the powershell pause command<\/p>\n If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n
\n$Product = $.Categories | Where-Object {$<\/em>.Type -eq ‘Product’} | Select-Object -First 1 -ExpandProperty Name
\n$_ | Add-Member -MemberType NoteProperty -Value $.UpdateIdentity.UpdateId -Name UpdateId
\n$<\/em> | Add-Member -MemberType NoteProperty -Value $.UpdateIdentity.RevisionNumber -Name RevisionNumber
\n$<\/em> | Add-Member -MemberType NoteProperty -Value $Product -Name Product -PassThru
\nWrite-Output $_
\n}
\n#Remove<\/span> null records and only return the fields we want
\n$history |
\nWhere-Object {![String]::IsNullOrWhiteSpace($_.title)} |
\nSelect-Object Result, Date, Title, SupportUrl, Product, UpdateId, RevisionNumber
\n}<\/p>\n
\nGet-Package -Name PSWindowsUpdate
\nSet-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
\nGet-WindowsUpdate -MicrosoftUpdate -Verbose
\nInstall-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot
\nwmic qfe list<\/p>\n
\n{
\nparam( [Parameter(Mandatory=$true)]
\n[int] $ResultCode
\n)
\n$Result = $ResultCode
\nswitch($ResultCode)
\n{
\n2
\n{
\n$Result = “Succeeded”
\n}
\n3
\n{
\n$Result = “Succeeded With Errors”
\n}
\n4
\n{
\n$Result = “Failed”
\n}
\n}
\nreturn $Result
\n}
\nfunction Get-WuaHistory
\n{<\/p>\n<\/a>Get a WUA Session<\/h1>\n
<\/a>Query the latest 1000 History starting with the first recordp<\/h1>\n
\n$Result = Convert-WuaResultCodeToName -ResultCode $_.ResultCode<\/p>\n<\/a>Make the properties hidden in com properties visible.<\/h1>\n
\n$Product = $.Categories | Where-Object {$<\/em>.Type -eq ‘Product’} | Select-Object -First 1 -ExpandProperty Name
\n$_ | Add-Member -MemberType NoteProperty -Value $.UpdateIdentity.UpdateId -Name UpdateId
\n$<\/em> | Add-Member -MemberType NoteProperty -Value $.UpdateIdentity.RevisionNumber -Name RevisionNumber
\n$<\/em> | Add-Member -MemberType NoteProperty -Value $Product -Name Product -PassThru
\nWrite-Output $_
\n}
\n#Remove<\/span> null records and only return the fields we want
\n$history |
\nWhere-Object {![String]::IsNullOrWhiteSpace($_.title)} |
\nSelect-Object Result, Date, Title, SupportUrl, Product, UpdateId, RevisionNumber
\n}<\/p>\n$Result | Export-Csv \"c:\\users\\lesliecalvo\\Desktop\\WindowsUpdate.csv\" -NoTypeInformation\n\nPause\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2021-12-21T15:17:12.000Z","url":"https://community.spiceworks.com/t/help/820245/4","author":{"@type":"Person","name":"PatrickFarrell","url":"https://community.spiceworks.com/u/PatrickFarrell"}},{"@type":"Answer","text":"