• New for Windows build 1702, SpecialPollInterval is contained by the MinPollInterval and MaxPollInterval Config registry values.

    See: Windows Time Service Tools and Settings

    but ….

    If i set MinPollInterval = 6, MaxPollInterval = 12 and SpecialPollIntervall = 3600 to the registry

    and call w32tm.exe with the parameter 0x8 or 0x9 like so /manualpeerlist:"[server1],0x9

    Which value is used then?

  • PowerShell is made of .NET and the .NET Framework has very good build in Classes to encrypt / decrypt.

    If you do not need PGP i recommend this module which do not need a third party tool:

    Encrypt / Decrypt files with PowerShell using symmetrical encryption

        #Create Key 
        $key = New-CryptographyKey -Algorithm AES -AsPlainText
        # now you can save the key as text elsewhere!
        #Encrypt the file 
        Protect-File '.secrets.txt' -Algorithm AES -KeyAsPlainText $key -RemoveSource 
        #Decrypt the file 
        Unprotect-File '.secrets.txt.AES' -Algorithm AES -KeyAsPlainText $key -RemoveSource


  • Hi Scott Baxter, I think your issue is best discussed in the PowerShell Forum.


    Did you try ?



  • Hi Wolfgang!


    Thank you for the good article.


    In the past I used the "offical" PowerShell install sripts:

    For Linux:


    Run it like so:

    wget https://aka.ms/install-powershell.sh; sudo bash install-powershell.sh -preview; rm install-powershell.sh

    For Windows:


    Run it like so:

    iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI -Preview"


    The difference between the installation of the released version (6) versus the Preview (7) version is the -Preview flag.


    See also:


  • I Think If you convert this Function into a Pipline able Function you do not need the Mutex.

    There for you can use the [CmdletBinding()] plus the "Begin {} Process {} End {}" blocks inside your Function.

    "$($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath('.'))" + "log.log"

    Points to the Current Path  not the Path of the executing script.
    If a command in the current Process is doing a CD the  the log is written in to the new path!!
    So your Logs can get spreaded over the filesystem.

    Is this intendet?

    For Datetime Format I suggest a UTC time Format.

    if you have servers spread across multiple timezones,
    all your event timestamps MUST be transported in UTC time (as String)
    this UTC MUST be calculated by the sender system and
    cannot be calculated by the receiver system.
    Because only the sender knows his locale timezone setting and dailight savings.

     # create UTC time string HH:mm:ss.mmm-+<UtcOffset.TotalMinutes>
    $Now = Get-Date

    Why do you not use the DebugRecord Object

    and what about the WarningRecord (Write-Warning) and VerboseRecord (Write-Verbose) Objects?

    Here I suggest you use an InputObject Parameter and Examin What Object Type do you process.

    With a Redirection Operator of  *>&1 you can Handle ALL PowerShell Streams in one Function.

    See: about_Redirection

    # will create access denied errors! AND
    # Redirect all Streams to success streams
    Get-ChildItem 'C:Windows' -recurse *>&1

    Then a Handler Function can look like this:

    Function Tee-StreamRecords {
                InputObjects which are NOT type of ErrorRecord or WarningRecord or DebugRecord or VerboseRecord or InformationRecord
                are allways passed thru without any further processing
                If InputObject is type of ErrorRecord or WarningRecord or DebugRecord or VerboseRecord or InformationRecord
                and if you wish to PassThru the InputObject, the handler has to return the Object !
             # is invoked if InputObject is type of WarningRecord
             # is invoked if InputObject is type of VerboseRecord 
             # is invoked if InputObject is type of ErrorRecord 
             # is invoked if InputObject is type of DebugRecord 
             # is invoked if InputObject is type of InformationRecord 
            # is invoked if InputObject is type of ErrorRecord or WarningRecord or DebugRecord or VerboseRecord or InformationRecord 
            switch ($InputObject)
                {$InputObject -is [System.Management.Automation.WarningRecord]} {
                   If($WarningHandler) { Invoke-Command $WarningHandler -ArgumentList $InputObject }
                   If($AllHandler) { Invoke-Command $AllHandler -ArgumentList $InputObject }
                {$InputObject -is [System.Management.Automation.VerboseRecord]} {
                    If($VerboseHandler) { Invoke-Command $VerboseHandler -ArgumentList $InputObject }
                    If($AllHandler) { Invoke-Command $AllHandler -ArgumentList $InputObject }
                {$InputObject -is [System.Management.Automation.ErrorRecord]} {
                    If($ErrorHandler) { Invoke-Command $ErrorHandler -ArgumentList $InputObject }
                    If($AllHandler) { Invoke-Command $AllHandler -ArgumentList $InputObject }
                {$InputObject -is [System.Management.Automation.DebugRecord]} {
                    If($DebugHandler) { Invoke-Command $DebugHandler -ArgumentList $InputObject }
                    If($AllHandler) { Invoke-Command $AllHandler -ArgumentList $InputObject }
                {$InputObject -is [System.Management.Automation.InformationRecord]} {
                    If($InformationHandler) { Invoke-Command $InformationHandler -ArgumentList $InputObject }
                    If($AllHandler) { Invoke-Command $AllHandler -ArgumentList $InputObject }
                default {
                   # InputObject seems to be an Object for the succes stream so allways pass it thru

    Then you can use the redirection like so:

    # log all ErrorRecord Objects to "$env:tempmy.log"
    Get-ChildItem 'C:Windows' -recurse *>&1 | Tee-StreamRecords -ErrorHandler { $Args[0] | Out-File "$env:tempmy.log" }

    For an uptodate version see Github:

  • Peter Kriegel became a registered member 2 years, 10 months ago

© 4sysops 2006 - 2022


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account