{"id":507,"date":"2014-01-09T09:29:46","date_gmt":"2014-01-09T09:29:46","guid":{"rendered":"http:\/\/giraffeit.com\/?p=507"},"modified":"2014-01-09T09:29:46","modified_gmt":"2014-01-09T09:29:46","slug":"emailpowershell","status":"publish","type":"post","link":"https:\/\/giraffeit.com\/index.php\/2014\/01\/09\/emailpowershell\/","title":{"rendered":"Servers pending reboots via WSUS and email"},"content":{"rendered":"<p>We have been working on a WSUS project , and its coming to a close. The client required information on which servers required rebooting to complete a patch.<\/p>\n<p>We came up with this script<\/p>\n<p>&nbsp;<\/p>\n<p>$csvfile=&#8217;drive WSUS Scriptsrebootpending.csv&#8217;<br \/>\nTry{<br \/>\n[void][reflection.assembly]::LoadWithPartialName(&#8216;Microsoft.UpdateServices.Administration&#8217;)<br \/>\n$wsus=[Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer()<br \/>\n$computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope<br \/>\n$computerScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot<br \/>\n$wsus.GetComputerTargets($computerScope) |<br \/>\nSelect FullDomainName,IPAddress,RequestedTargetGroupName |<br \/>\nExport-Csv $csvfile -NoType<\/p>\n<p>}<br \/>\ncatch{<br \/>\nthrow<br \/>\n}<\/p>\n<p>$smtpServer = &#8220;your smtp server&#8221;<br \/>\n$msg = new-object Net.Mail.MailMessage<br \/>\n$att = new-object Net.Mail.Attachment($csvfile)<br \/>\n$smtp = new-object Net.Mail.SmtpClient($smtpServer)<br \/>\n$msg.From = &#8220;your address&#8221;<br \/>\n$msg.To.Add(&#8220;your address&#8221;)<br \/>\n$msg.Subject = &#8220;pending reboots&#8221;<br \/>\n$msg.Body = &#8220;Check attachment:&#8221;,$messagebody<br \/>\n#&#8221;Here is todays copy for &#8221;<br \/>\n$msg.Attachments.Add($att)<br \/>\n$smtp.Send($msg)<br \/>\n#$att.Dispose()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have been working on a WSUS project , and its coming to a close. The client required information on which servers required rebooting to complete a patch. We came up with this script &nbsp; $csvfile=&#8217;drive WSUS Scriptsrebootpending.csv&#8217; Try{ [void][reflection.assembly]::LoadWithPartialName(&#8216;Microsoft.UpdateServices.Administration&#8217;) $wsus=[Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer() $computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope $computerScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot $wsus.GetComputerTargets($computerScope) | Select FullDomainName,IPAddress,RequestedTargetGroupName | Export-Csv $csvfile &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/giraffeit.com\/index.php\/2014\/01\/09\/emailpowershell\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Servers pending reboots via WSUS and email&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-507","post","type-post","status-publish","format-standard","hentry","category-bog"],"_links":{"self":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/comments?post=507"}],"version-history":[{"count":0,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/507\/revisions"}],"wp:attachment":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/media?parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/categories?post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/tags?post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}