{"id":32,"date":"2006-05-21T18:46:00","date_gmt":"2006-05-21T22:46:00","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/2006\/05\/21\/create-timestamp-log-in-powershell\/"},"modified":"2009-08-05T13:04:42","modified_gmt":"2009-08-05T17:04:42","slug":"create-timestamp-log-in-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/","title":{"rendered":"Create Timestamp log in PowerShell"},"content":{"rendered":"<p><span style=\"font-family:trebuchet ms;\">Very often in administrative scripting you will want to create a log file where the filename is a timestamp like  200605201912.log. Since PowerShell is based on .NET Framework objects, we can take advantage of the DateTime object which is obtained by using the Get-Date cmdlet:<\/span><\/p>\n<p><span style=\"font-family:courier new;\">PS C:\\> get-date<\/span><span style=\"font-family:courier new;\">Sunday, May 21, 2006 6:47:03 PM<\/span><br \/><span style=\"font-family:trebuchet ms;\">If we create a variable with this cmdlet, we have access to all of the object's properties.<\/span><\/p>\n<p><span style=\"font-family:lucida grande;\">P<\/span><span style=\"font-family:courier new;\">S C:\\> $now=get-date<\/span><span style=\"font-family:courier new;\"><br \/>PS C:\\> $now|get-member -membertype properties<br \/><\/span><span style=\"font-family:courier new;\">TypeName: System.DateTime<\/span><span style=\"font-family:courier new;\">Name        MemberType     Definition<br \/><\/span><span style=\"font-family:courier new;\">----        ----------     ----------<\/span><span style=\"font-family:courier new;\"><br \/>DisplayHint NoteProperty   Microsoft.PowerShell.Commands.DisplayHintType<br \/>D<\/span><span style=\"font-family:courier new;\">Date        Property       System.DateTime Date {get;}<br \/><\/span><span style=\"font-family:courier new;\">Day         Property       System.Int32 Day {get;}<\/span><span style=\"font-family:courier new;\"><br \/>DayOfWeek   Property       System.DayOfWeek DayOfWeek {get;}<br \/><\/span><span style=\"font-family:courier new;\">DayOfYear   Property       System.Int32 DayOfYear {get;}<\/span><span style=\"font-family:courier new;\"><br \/>Hour        Property       System.Int32 Hour {get;}<br \/><\/span><span style=\"font-family:courier new;\">Kind        Property       System.DateTimeKind Kind {get;}<br \/><\/span><span style=\"font-family:courier new;\">Millisecond Property       System.Int32 Millisecond {get;}<br \/><\/span><span style=\"font-family:courier new;\">Minute      Property       System.Int32 Minute {get;}<br \/><\/span><span style=\"font-family:courier new;\">Month       Property       System.Int32 Month {get;}<br \/><\/span><span style=\"font-family:courier new;\">Second      Property       System.Int32 Second {get;}<br \/><\/span><span style=\"font-family:courier new;\">Ticks       Property       System.Int64 Ticks {get;}<\/span><span style=\"font-family:courier new;\"><br \/>TimeOfDay   Property       System.TimeSpan TimeOfDay {get;}<br \/><\/span><span style=\"font-family:courier new;\">Year        Property       System.Int32 Year {get;}<\/span><span style=\"font-family:courier new;\"><br \/>DateTime    ScriptProperty System.Object DateTime {get=if<\/p>\n<p><\/span><span style=\"font-family:courier new;\">PS C:\\><\/p>\n<p><\/span><span style=\"font-family:trebuchet ms;\">With this object we can build a timestamp name by returning the year, month, day and minute properties. We can even go so far as to get second and millisecond if we need that level of precision.  To simplify the process, I've written a function called logstamp that will return a timestamp in the form of YearMonthDayMinute.<\/span><\/p>\n<p><span style=\"font-family:courier new;\">Function logstamp {<br \/><\/span><span style=\"font-family:courier new;\">$now=get-Date<\/span><span style=\"font-family:courier new;\"><br \/>$yr=$now.Year.ToString()<br \/><\/span><span style=\"font-family:courier new;\">$mo=$now.Month.ToString()<\/span><span style=\"font-family:courier new;\"><br \/>$dy=$now.Day.ToString()<br \/><\/span><span style=\"font-family:courier new;\">$hr=$now.Hour.ToString()<br \/><\/span><span style=\"font-family:courier new;\">$mi=$now.Minute.ToString()<\/span><span style=\"font-family:courier new;\"><br \/>if ($mo.length -lt 2) {<br \/><\/span><span style=\"font-family:courier new;\">$mo=\"0\"+$mo #pad single digit months with leading zero<br \/><\/span><span style=\"font-family:courier new;\">}<\/span><span style=\"font-family:courier new;\"><br \/>if ($dy.length -lt 2) {<br \/><\/span><span style=\"font-family:courier new;\">$dy=\"0\"+$dy #pad single digit day with leading zero<br \/><\/span><span style=\"font-family:courier new;\">}<br \/><\/span><span style=\"font-family:courier new;\">if ($hr.length -lt 2) {<br \/><\/span><span style=\"font-family:courier new;\">$hr=\"0\"+$hr #pad single digit hour with leading zero<br \/><\/span><span style=\"font-family:courier new;\">}<br \/><\/span><span style=\"font-family:courier new;\">if ($mi.length -lt 2) {<br \/><\/span><span style=\"font-family:courier new;\">$mi=\"0\"+$mi #pad single digit minute with leading zero<br \/><\/span><span style=\"font-family:courier new;\">}<\/span><span style=\"font-family:courier new;\"><br \/>write-output $yr$mo$dy$hr$mi<\/span><span style=\"font-family:lucida grande;\"><br \/>}<\/span><\/p>\n<p><span style=\"font-family:trebuchet ms;\">I'm using the ToString method to convert the datetime object into a string. I do that so that I can check the length property of the month, day and minute variables. If the length is less than 2 then I want to pad it with a leading zero. This makes all my filenames line up neatly.<\/span><\/p>\n<p><span style=\"font-family:trebuchet ms;\">When I enter this function into PowerShell I can call it at any time and it will return a timestamp string.<\/span><\/p>\n<p><span style=\"font-family:courier new;\">PS C:\\> logstamp<\/span><br \/><span style=\"font-family:courier new;\">200605211853<\/span><\/p>\n<p><span style=\"font-family:trebuchet ms;\">To build a variable for the filename we use something like this:<\/span><\/p>\n<p><span style=\"font-family:courier new;\">PS C:\\> $stamp=logstamp<\/span><span style=\"font-family:courier new;\"><br \/>PS C:\\> $filename=$stamp+\".log\"<\/span><span style=\"font-family:courier new;\"><br \/>PS C:\\> $filename<\/span><span style=\"font-family:courier new;\">200605211855.log<\/span><span style=\"font-family:trebuchet ms;\"><\/p>\n<p>I can now use the $filename variable to create the log file using the New-Item cmdlet.<\/span><\/p>\n<p><span style=\"font-family:courier new;\">PS C:\\> new-item . -name $filename -type \"file\" -value \"Audit Log<br \/>\"<\/span><span style=\"font-family:courier new;\">Directory: Microsoft.PowerShell.Core\\FileSystem::C:\\<\/span><span style=\"font-family:courier new;\"><br \/>Mode                LastWriteTime     Length Name<\/span><span style=\"font-family:courier new;\">----                -------------     ------<br \/>----<\/span><span style=\"font-family:courier new;\">-a---         5\/21\/2006   6:57 PM          9 200605211855.log<br \/><\/span><span style=\"font-family:courier new;\">PS C:\\> get-content $filename<\/span><span style=\"font-family:courier new;\"><br \/>Audit Log<\/span><span style=\"font-family:courier new;\"><br \/>PS C:\\><\/span><span style=\"font-family:trebuchet ms;\"><\/p>\n<p>If you find yourself using this feature, you may want to put the function in your PowerShell profile so that it is always available.<\/span><\/p>\n<p><font face=Tahoma size=1>Technorati tags:<br \/><a href=\"http:\/\/www.technorati.com\/tags\/powershell\" rel=\"tag\">PowerShell<\/a><br \/><a href=\"http:\/\/www.technorati.com\/tags\/scripting\" rel=\"tag\">Scripting<\/a><br \/><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Very often in administrative scripting you will want to create a log file where the filename is a timestamp like 200605201912.log. Since PowerShell is based on .NET Framework objects, we can take advantage of the DateTime object which is obtained by using the Get-Date cmdlet: PS C:\\> get-dateSunday, May 21, 2006 6:47:03 PMIf we create&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create Timestamp log in PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Timestamp log in PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Very often in administrative scripting you will want to create a log file where the filename is a timestamp like 200605201912.log. Since PowerShell is based on .NET Framework objects, we can take advantage of the DateTime object which is obtained by using the Get-Date cmdlet: PS C:&gt; get-dateSunday, May 21, 2006 6:47:03 PMIf we create...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2006-05-21T22:46:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2009-08-05T17:04:42+00:00\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/32\\\/create-timestamp-log-in-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/32\\\/create-timestamp-log-in-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Create Timestamp log in PowerShell\",\"datePublished\":\"2006-05-21T22:46:00+00:00\",\"dateModified\":\"2009-08-05T17:04:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/32\\\/create-timestamp-log-in-powershell\\\/\"},\"wordCount\":510,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/32\\\/create-timestamp-log-in-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/32\\\/create-timestamp-log-in-powershell\\\/\",\"name\":\"Create Timestamp log in PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2006-05-21T22:46:00+00:00\",\"dateModified\":\"2009-08-05T17:04:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/32\\\/create-timestamp-log-in-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/32\\\/create-timestamp-log-in-powershell\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/32\\\/create-timestamp-log-in-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create Timestamp log in PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Timestamp log in PowerShell &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Create Timestamp log in PowerShell &#8226; The Lonely Administrator","og_description":"Very often in administrative scripting you will want to create a log file where the filename is a timestamp like 200605201912.log. Since PowerShell is based on .NET Framework objects, we can take advantage of the DateTime object which is obtained by using the Get-Date cmdlet: PS C:> get-dateSunday, May 21, 2006 6:47:03 PMIf we create...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2006-05-21T22:46:00+00:00","article_modified_time":"2009-08-05T17:04:42+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Create Timestamp log in PowerShell","datePublished":"2006-05-21T22:46:00+00:00","dateModified":"2009-08-05T17:04:42+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/"},"wordCount":510,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/","name":"Create Timestamp log in PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2006-05-21T22:46:00+00:00","dateModified":"2009-08-05T17:04:42+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/32\/create-timestamp-log-in-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Create Timestamp log in PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":455,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/455\/get-printer\/","url_meta":{"origin":32,"position":0},"title":"Get-Printer","author":"Jeffery Hicks","date":"October 16, 2009","format":false,"excerpt":"I think Out-Printer is a very handy cmdlet, and one that doesn\u2019t get used much. Pipe any cmdlet to it and the output will be printed to your default printer. You use it the same way you would Out-File except output is printed instead of saved to a file. The\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2148,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2148\/get-cmdlet-help-url\/","url_meta":{"origin":32,"position":1},"title":"Get Cmdlet Help URL","author":"Jeffery Hicks","date":"April 2, 2012","format":false,"excerpt":"I was toying around with PowerShell help this morning and as usually happens one thing leads to another. When you run Get-Help, or use the wrapper function Help, you are actually getting an object: MamlCommandHelpInfo. This object has properties that you are use to seeing like name and synopsis. PS\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":531,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/531\/think-objectively\/","url_meta":{"origin":32,"position":2},"title":"Think Objectively","author":"Jeffery Hicks","date":"December 14, 2009","format":false,"excerpt":"A challenge many new comers to PowerShell face, especially those arriving with a VBScript background, and one that I often talk about, is shifting gears from working with text to working with objects. Here\u2019s a good example. The Win32_OperatingSystem class returns a value for TotalVisibleMemorySize, which should be the amount\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8041,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8041\/get-group-policy-links-with-powershell\/","url_meta":{"origin":32,"position":3},"title":"Get Group Policy Links with PowerShell","author":"Jeffery Hicks","date":"January 18, 2021","format":false,"excerpt":"I was chatting with my friend Gladys Kravitz about Group Policy reporting stuff recently,. and the discussion led me to dust off some old code I had for getting Group Policy links using PowerShell. The GroupPolicy module has a Set-GPLink command, but nothing that easily shows you what GPOs are\u2026","rel":"","context":"In &quot;Active Directory&quot;","block_context":{"text":"Active Directory","link":"https:\/\/jdhitsolutions.com\/blog\/category\/active-directory\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/01\/get-gpinherticance-1.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":6478,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6478\/powershell-scripting-getting-git-size-retooled\/","url_meta":{"origin":32,"position":4},"title":"Getting Git Size with PowerShell Retooled","author":"Jeffery Hicks","date":"January 30, 2019","format":false,"excerpt":"A few days ago I wrote about my experiences in designing a PowerShell function that reports on the size of the hidden .git folder. In that version of the function I decided to include a parameter that would permit the user to get the size pre-formatted as either KB, MB\u2026","rel":"","context":"In &quot;Git&quot;","block_context":{"text":"Git","link":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-29.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-29.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-29.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/01\/image_thumb-29.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":97,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/97\/powershell-get-content\/","url_meta":{"origin":32,"position":5},"title":"PowerShell Get Content","author":"Jeffery Hicks","date":"February 13, 2007","format":false,"excerpt":"One slick trick you can do in PowerShell with text files that's difficult to accomplish without extra tools is to display sections of text files without showing the entire file. When you use the Get-Content cmdlet, the resulting content is treated as an array of strings. This means you can\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}