{"id":302,"date":"2017-05-16T13:28:12","date_gmt":"2017-05-16T19:28:12","guid":{"rendered":"https:\/\/sysadminnightmare.com\/?p=302"},"modified":"2017-05-16T13:28:12","modified_gmt":"2017-05-16T19:28:12","slug":"powershell-getting-formatted-date-info","status":"publish","type":"post","link":"https:\/\/sysadminnightmare.com\/index.php\/2017\/05\/16\/powershell-getting-formatted-date-info\/","title":{"rendered":"Powershell &#8211; Getting Formatted Date Info"},"content":{"rendered":"<p>This is a simple one, want to get today, yesterday, last month or last year .. try this<br \/>\n<code><br \/>\n$Date = Get-Date<br \/>\n$Today = $Date | Get-date -Format MM\/dd\/yyyy<br \/>\n$Yesterday = $Date.AddDays(-1) | Get-Date -Format MM\/dd\/yyyy<br \/>\n$LastMonth = $Date.AddMonths(-1) | Get-date -Format MM\/dd\/yyyy<br \/>\n$LastYear = $Date.AddYears(-1) | Get-Date -Format MM\/dd\/yyyy<br \/>\n<\/code><\/p>\n<p>You get the idea .. get last 6 months:<br \/>\n<code>$Last6Months = $Date.AddMonths(-6) | Get-date -Format MM\/dd\/yyyy<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a simple one, want to get today, yesterday, last month or last year .. try this $Date = Get-Date $Today = $Date | Get-date -Format MM\/dd\/yyyy $Yesterday = $Date.AddDays(-1) | Get-Date -Format MM\/dd\/yyyy $LastMonth = $Date.AddMonths(-1) | Get-date -Format MM\/dd\/yyyy $LastYear = $Date.AddYears(-1) | Get-Date -Format MM\/dd\/yyyy You&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/sysadminnightmare.com\/index.php\/2017\/05\/16\/powershell-getting-formatted-date-info\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2,7,8],"tags":[],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-admin","category-powershell-2","category-tech-tips-101"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2bgeE-4S","_links":{"self":[{"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":2,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":304,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions\/304"}],"wp:attachment":[{"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysadminnightmare.com\/index.php\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}