Subscribe: Comments for Dmitry's PowerBlog: PowerShell and beyond
Preview: Comments for Dmitry's PowerBlog: PowerShell and beyond

Comments for Dmitry's Blog: Cloud, PowerShell and beyond

Dmitry Sotnikov's view on Cloud, PowerShell, PowerGUI and everything he sees around

Last Build Date: Thu, 08 Mar 2018 16:40:27 +0000


Comment on Freeing up memory in PowerShell using garbage collector by Dustin Saunders

Thu, 08 Mar 2018 16:40:27 +0000

Yes-- modulo is used for an "every x iterations" in this scenario. In your case you'd have to set $i = 0 at some point. Neither is right nor wrong, but if you are using $i as something like a progress bar you'd lose your place or would have to create a new variable just for that which would be wasteful.

Comment on Measure-Latest: finding latest date/time by zj

Wed, 21 Feb 2018 22:43:34 +0000

I know this is very old post, I learned a lots from you, including your 'Pro Windows PowerShell' book, so I would like your comment. I think issue that you experienced with standard measure-object cmdlet failing for DateTime values is related to object being passed is the String and measure-object does string ordering. If you pass DateTime type then it looks that works properly ( got same results as your example): (dir c:\temp | foreach { [datetime []] $_.LastWriteTime} | Measure-Object -Maximum).Maximum

Comment on Prevent desktop lock or screensaver with PowerShell by Brecht Gijbels

Mon, 05 Feb 2018 07:20:58 +0000

Improved the script with PowerShell code only and cleaned up a bit of the timer loop for readability: Param ( [Parameter(Mandatory)] [String]$Until, [Switch]$Logoff ) Do { [void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') [System.Windows.Forms.SendKeys]::SendWait("{PRTSC}") Start-Sleep -Seconds 60 If ((Get-Date) -gt (Get-Date $Until)) { If ($Logoff) { logoff.exe } Else { Break } } } While ($true)

Comment on Freeing up memory in PowerShell using garbage collector by Jon Czerwinski (@JonCzerwinski)

Tue, 30 Jan 2018 10:50:55 +0000

Jeremy, In your example, GC would only run once, at 200 items, and either never again, or you're resetting $i to 0 and counting back up. Your $i would only be used to track when you wanted GC to run. Dmitry's using $i as a counter. Presumably elsewhere he's reporting progress or at the end reporting total objects processed. The use of modulus here is so every 200 objects, he runs garbage collection. He's getting his trigger for free as a side effect.

Comment on VBScript to PowerShell Converter by Anonymous

Wed, 17 Jan 2018 17:56:58 +0000

If anyone needs the specific version mentioned, here's the link:

Comment on Execute PowerShell Scripts from Your Smartphone by Adrian

Mon, 27 Nov 2017 01:19:24 +0000

I gave this a shot with a simple command, Get-date, but got an error on the Outlook script here: Sub SaveAsText(MyMail As MailItem) Compile error: sub or function not defined Any ideas?

Comment on Download Links for PowerGUI and QAD cmdlets by Anonymous

Thu, 16 Nov 2017 09:43:12 +0000

Thanks Grossi, exactly what I needed :) -Ido

Comment on Clear AD attribute by Cliff

Wed, 15 Nov 2017 14:39:29 +0000

Again Dmitry saves the day!

Comment on Download Links for PowerGUI and QAD cmdlets by Anonymous

Tue, 14 Nov 2017 13:11:34 +0000

Hi Dmitriy, i use this link : Grossi

Comment on Passing parameters to -EncodedCommand by Lee Fitzsimmons

Mon, 13 Nov 2017 13:49:33 +0000

Note that the above only works when executed from cmd, not a powershell prompt. In powershell, in.readline will take each space-separated item echoed as a separate line. the code can be easily modified for this scenario