{"id":87,"date":"2018-05-17T20:00:52","date_gmt":"2018-05-17T20:00:52","guid":{"rendered":"https:\/\/www.atlanta247.com\/blog\/?p=87"},"modified":"2018-12-26T20:17:44","modified_gmt":"2018-12-26T20:17:44","slug":"powershell-more-code-snippits","status":"publish","type":"post","link":"https:\/\/www.atlanta247.com\/blog\/2018\/05\/17\/powershell-more-code-snippits\/","title":{"rendered":"Powershell &#8211; More Code Snippits"},"content":{"rendered":"\n<p>Getting the Date:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>$now = Get-Date <\/p><\/blockquote>\n\n\n\n<p>I like this format for File names:  <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p> $Cdate = get-date -f &#8220;yyyy-MM-dd-HH-mm-ss&#8221;  <\/p><\/blockquote>\n\n\n\n<p>How to log to a file:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>#<br> Log to file<br> #<br> $STR_Error = $null<br> $NOW = Get-Date -Format s<br> $STR_Error = $NOW + &#8220;, &#8221; + $STR_AffectedGroupName + &#8220;, FAILED, AD Group not found.,&#8221; + $STR_ADGETERROR<br> Echo $STR_Error | Out-File $log -Append<br> $STR_Error = $null<\/p><\/blockquote>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting the Date: $now = Get-Date I like this format for File names: $Cdate = get-date -f &#8220;yyyy-MM-dd-HH-mm-ss&#8221; How to log to a file: # Log to file # $STR_Error = $null $NOW = Get-Date -Format s $STR_Error = $NOW + &#8220;, &#8221; + $STR_AffectedGroupName + &#8220;, FAILED, AD Group not found.,&#8221; + $STR_ADGETERROR Echo &hellip; <a href=\"https:\/\/www.atlanta247.com\/blog\/2018\/05\/17\/powershell-more-code-snippits\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Powershell &#8211; More Code Snippits<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8],"tags":[16,17,15],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-dates","tag-files","tag-powershell"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":1,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":88,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/87\/revisions\/88"}],"wp:attachment":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}