Enable SMB Signing

email me

Scripting

reg add “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanWorkStation\Parameters” /v “RequireSecuritySignature” /t REG_DWORD /d 1 /f

reg add “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanWorkStation\Parameters” /v “EnableSecuritySignature” /t REG_DWORD /d 1 /f

reg add “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Parameters” /v “RequireSecuritySignature” /t REG_DWORD /d 1 /f

reg add “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Parameters” /v “EnableSecuritySignature” /t REG_DWORD /d 1 /f

 

Return the current state of  SMB
Get-SmbServerConfiguration | Select EnableSMB1Protocol, EnableSMB2Protocol

Disables the SMBv1 on the SMB server by running the below command
Set-SmbServerConfiguration -EnableSMB1Protocol $false

Disables the SMBv2 and SMBv3 on the SMB server by running the below command
Set-SmbServerConfiguration -EnableSMB2Protocol $false

Enables the SMBv1 on the SMB server by running the below command
Set-SmbServerConfiguration -EnableSMB1Protocol $true

Enables the SMBv2 and SMBv3 on the SMB server by running the below command
Set-SmbServerConfiguration -EnableSMB2Protocol $true


Using Windows PowerShell 2.0 or later version

Disables the SMBv1 on the SMB server by running the below command
Set-ItemProperty -Path “HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters” SMB1 -Value 0 –Force

Disables the SMBv2 and SMBv3 on the SMB server by running the below command
Set-ItemProperty –Path “HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters” SMB2 –Value 0 –Force

Enables the SMBv1 on the SMB server by running the below command
Set-ItemProperty –Path “HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters” SMB1 –Value 1 –Force

Enables the SMBv2 and SMBv3 on the SMB server by running the below command
Set-ItemProperty -Path “HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters” SMB2 -Value 1 -Force

Batch – Manage Windows Updates by Script

email me

Manage Windows Update via a script.

@echo off

set sysPath=C:\Windows\system32

:: STOP SERVICE
%sysPath%\net stop wuauserv

:: REMOVE KEYS
%sysPath%\reg DELETE “HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update” /v “LastWaitTimeout” /reg:64 /f

%sysPath%\reg DELETE “HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update” /v “DetectionStartTime” /reg:64 /f


%sysPath%\reg DELETE “HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update” /v “NextDetectionTime” /reg:64 /f

:: ADD REG KEYS

:: AUTO UPDATE IS ENABLED
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “NoAutoUpdate” /t REG_DWORD /d “0” /reg:64 /f

:: DOWNLOAD AND INSTALL
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “AUOptions” /t REG_DWORD /d “3” /reg:64 /f

:: 0 IS SET TO EVERY DAY
:: but we could schedule time and day
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “ScheduledInstallDay” /t REG_DWORD /d “0” /reg:64 /f

:: ADD 2400 TIME HERE BY HOUR

%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “ScheduledInstallTime” /t REG_DWORD /d “19” /reg:64 /f

:: USE AUTO REBOOT WHILE LOGGED IN
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “NoAutoRebootWithLoggedOnUsers” /t REG_DWORD /d “0” /reg:64 /f

:: YES INSTALL MINOR UPDATES
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “AutoInstallMinorUpdates” /t REG_DWORD /d “1” /reg:64 /f

:: PROMPT FOR REBOOT IS ENABLED AND SET FOR 60 MINUTES – WARN USER EVERY HOUR
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “RebootRelaunchTimeoutEnabled” /t REG_DWORD /d “00000001” /reg:64 /f
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “RebootRelaunchTimeout” /t REG_DWORD /d “60” /reg:64 /f

:: FOR A SCHEDULED INSTALL, RETRY A MISSED INSTALL EVERY 15 MINUTES 
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “RescheduleWaitTimeEnabled” /t REG_DWORD /d “00000001” /reg:64 /f
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “RescheduleWaitTime” /t REG_DWORD /d “15” /reg:64 /f

:: CHECK FOR UPDATES EVERY 22 HOURS – WHICH IS THE DEFAULT IF ENABLED
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “DetectionFrequencyEnabled” /t REG_DWORD /d “1” /reg:64 /f

:: FOR A SCHEDULED REBOOT, IT IS ENABLED AND SET FOR 8 HOURS TO WAIT BEFORE PROCEEDING WITH A SCHEDULED RESTART
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “RebootWarningTimeoutEnabled” /t REG_DWORD /d “1” /reg:64 /f
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “RebootWarningTimeout” /t REG_DWORD /d “480” /reg:64 /f

:: USE WSUS IS DISABLED
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “UseWUServer” /t REG_DWORD /d “0” /reg:64 /f

:: ALLOW SHUTDOWN IS ENABLED
%sysPath%\reg ADD “HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU” /v “NoAUShutdownOption” /t REG_DWORD /d “0” /reg:64 /f

:: REGISTER COMPONENTS
%sysPath%\regsvr32 wuaueng.dll /s
%sysPath%\regsvr32 wuauserv.dll /s
%sysPath%\regsvr32 wucltui.dll /s
%sysPath%\regsvr32 wups.dll /s
%sysPath%\regsvr32 wuweb.dll /s
%sysPath%\regsvr32 iuengine.dll /s

%sysPath%\wuauclt /resetauthorization /detectnow

:: START SERVICE
%sysPath%\net start wuauserv

%sysPath%\wuauclt /ReportNow /DetectNow
:: %sysPath%\wuauclt /UpdateNow

:: not used
::%sysPath%\wuauclt /ShowWU

::NOTES

::NoAutoUpdate: Reg_DWORD
:: 0: Automatic Updates is enabled
:: 1: Automatic Updates is disabled

:: AUOptions: Reg_DWORD
:: 1: Keep my computer up to date has been disabled in Automatic Updates
:: 2: Notify of download and installation
:: 3: Automatically download and notify of installation
:: 4: Automatically download and scheduled installation

:: ScheduledInstallDay: Reg_DWORD
:: 0: Every day
:: 1 through 7: The days of the week from Sunday (1) to Saturday (7)

:: ScheduledInstallTime: Reg_DWORD
:: n equals the time of day in a 24-hour format (0-23).

:: UseWUServer: Reg_DWORD
:: 0 = disabled
:: 1 = enable, to configure a WSUS

:: RescheduleWaitTime: Reg_DWORD
:: 1-60 minutes wait time

:: NoAutoRebootWithLoggedOnUsers: Reg_DWORD
:: 0 = true
:: 1 = false

:: AutoInstallMinorUpdates: Reg_DWORD
:: 0 = false
:: 1 = true

Disable DES-CBC3-SHA

email me

Scripting

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\Triple DES 168” /v “Enabled” /t REG_DWORD /d 0 /f

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\DES 56/56” /v “Enabled” /t REG_DWORD /d 0 /f

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\NULL” /v “Enabled” /t REG_DWORD /d 0 /f

 

Save as reg file

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\DES 56/56]
“Enabled”=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\NULL]
“Enabled”=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\Triple DES 168]
“Enabled”=dword:00000000

Disable 3DES

email me

Scripting

reg.exe add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\Triple DES 168” /v “Enabled” /t REG_DWORD /d 0 /f

 

Save as reg file

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\Triple DES 168]
“Enabled”=dword:00000000

 

Notes

20160826 – Sweet32 attack

Disable TLS 1.0

email me

TLS 1.0 is disabled by default in Windows 10 build 1709. See notes for more info.

 

Scripting

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client” /v “DisabledByDefault” /t REG_DWORD /d 1 /f

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client” /v “Enabled” /t REG_DWORD /d 0 /f

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server” /v “DisabledByDefault” /t REG_DWORD /d 1 /f

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server” /v “Enabled” /t REG_DWORD /d 0 /f

 

Save as reg file

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
“DisabledByDefault”=dword:00000001
“Enabled”=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
“DisabledByDefault”=dword:00000001
“Enabled”=dword:00000000

 

Notes

see SSL and TLS 1.0 No Longer Acceptable for PCI Compliance

Added support for the following cipher suites:

TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (RFC 5289) in Windows 10, version 1507
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (RFC 5289) in Windows 10, version 1507

 

DisabledByDefault change for the following cipher suites:

TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 (RFC 5246) in Windows 10, version 1703
TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 (RFC 5246) in Windows 10, version 1703
TLS_DHE_DSS_WITH_AES_256_CBC_SHA (RFC 5246) in Windows 10, version 1703
TLS_DHE_DSS_WITH_AES_128_CBC_SHA (RFC 5246) in Windows 10, version 1703
TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA (RFC 5246) in Windows 10, version 1703
TLS_RSA_WITH_RC4_128_SHA in Windows 10, version 1709
TLS_RSA_WITH_RC4_128_MD5 in Windows 10, version 1709

Disable RC4

email me

RC4 was designed in 1987 by Ron Rivest and is one of the most widely software stream cipher and used in popular protocols, such as SSL (protect Internet traffic), WEP (secure wireless networks) and PDF. It’s considered to be fast and simple in terms of software.

RC4 generates a pseudo-random stream of bits (a key-stream). As with any stream cipher, these can be used for encryption by combining it with the plaintext using bit-wise exclusive-or. Decryption is performed the same way (since exclusive-or is a symmetric operation). The reason many software vendors are dropping support for RC4 is due to the growing attack space and available exploits online. Because of these security concerns, Microsoft has also removed browser support for RC4 in IE11 and Edge.

To disable RC4 in your enterprise, create a script that will toggle these reg keys from 1 to 0 (you could use reg.exe to do this).

 
Scripting

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 128/128” /v “Enabled” /t REG_DWORD /d 0 /f

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 40/128” /v “Enabled” /t REG_DWORD /d 0 /f

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 56/128” /v “Enabled” /t REG_DWORD /d 0 /f

 

Save as reg file

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 128/128]
“Enabled”=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 40/128]
“Enabled”=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC4 56/128]
“Enabled”=dword:00000000

 

Reference

RC4 will no longer be supported in Microsoft Edge and IE11 [Updated]

How to restrict the use of certain cryptographic algorithms and protocols in Schannel.dll

Killing RC4: The Long Goodbye

Windows – Updating Specific Elements in the Computer Description

email me

This is a script I created to run in SCCM during a Windows 7 to Windows 10 upgrade. In this scenario, WIN7 was a part of the computer description on the local machine. I wanted to update only the part that said WIN7—as there was other text in the description I wanted to keep.

To do this, I used a simple batch file with reg query to get the current key info. Then I scanned it as a string. If WIN7 existed, replace it with WIN10. Once it was replaced in that string, I used reg add to just import the updated OS into the computer description (easy). I added some extra output, just to make sure everything was working. This eventually was compiled into an EXE and added to a SCCM task sequence.

The reason I like using batch scripting sometimes?

Run time: 2 seconds
Memory used: 680 KB
Compiled file size: 158 KB

 

Script

@echo off
title Update Computer description
setlocal enabledelayedexpansion

cls

:: original description ABC WIN7 BITLOCKER 10-26-17
:: new description ABC WIN10 BITLOCKER 10-26-17

set rKey1=
set rKey2=
set RegData=
set RegPath=
set RegValue=
set model=
set bValue=FALSE

 
:: REG PATH TO SCAN
set RegPath=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanServer\Parameters
set RegValue=srvcomment

:: returns model
call :pcmodel

:: CHECK REG FOR W7
call :scan
call :rKey1
set bValue=FALSE

:: SCAN AND UPDATE OS IN STRING
SET _tmp=%RegData%
SET _newData=%_tmp:WIN7=WIN10%
::SET _newData=%_tmp:WIN7=WIN10% %model%

:: APPLY REG UPDATE
Echo Update Reg Key…
reg add “%RegPath%” /v “%RegValue%” /t REG_SZ /d “%_newData%” /f /reg:64
echo.

:: CHECK REG FOR W10
call :scan
call :rKey2
set bValue=FALSE

:: CLEAR SESSION
set rKey1=
set rKey2=
set RegData=
set bValue=
set RegPath=
pause

exit

:: ————————————

:rKey1
echo %RegData% | FIND “WIN7” && set bValue=FOUND_WIN7
if %bValue%==FALSE exit
echo.
goto :EOF

:rKey2
echo %RegData% | FIND “WIN10” && set bValue=FOUND_WIN10
echo %bValue%
echo.
goto :done
:scan
FOR /F “tokens=2*” %%a IN (‘REG.EXE QUERY “%RegPath%” /V “%RegValue%”‘) DO SET RegData=%%b
goto :EOF

:pcmodel
:: a little something extra I’ve thrown in
FOR /F “tokens=2 delims==” %%m IN (‘WMIC csproduct GET Name /VALUE ^| FIND /I “Name=”‘) do set model=%%m
goto :EOF

:done
exit /b 0

Windows 7 – Clear Frequently Used Apps

email me

There are two methods to clear the Frequently used applications on the Start Menu.

#1

One is by using group policy.

User Configuration > Administrative Templates > Start Menu and Taskbar > Remove frequent programs list from the Start Menu.

#2

The second one is by deleting the reg key that holds the shortcut data. Note, this data is encrypted using ROT-13 (yeah, I know…Microsoft strikes again). You may have to kill explorer.exe and reload it for it to take effect (or just reboot).

Screenshot of the reg keys

Frequent Apps

 

Reg Key

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count

If you’re managing an enterprise—where computers have more than one user—the reg key must be deleted from each user’s reg hive. To scan through the respective registry hives, I created this script to do the scan and the reg key delete.

 

Script

This can run as System Account or Administrator.

Option Explicit

Dim objShell, strComputer, objWMIService, objRegistry, strKeyPath, strValueName, strSubPath

Dim objAccount, objSubkey, arrSubkeys, strValue, strUser

on error resume next

Set objShell = CreateObject("Wscript.Shell")

Const HKEY_LOCAL_MACHINE = &H80000002

Const OverwriteExisting = TRUE

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\ProfileList"

objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys

For Each objSubkey In arrSubkeys

on error resume next

strValueName = "ProfileImagePath"

strSubPath = strKeyPath & "\" & objSubkey

objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objAccount = objWMIService.Get("Win32_SID.SID='" & objSubkey & "'")

strUser = objAccount.AccountName

objSubkey = trim(objSubkey)'trims whitespace

strUser = trim(strUser)'trims whitespace

'LOGIC TO DETERMINE IF REGISTRY HIVE IS TO BE ACCESSED

if strUser = "SYSTEM" then strUser=""

if strUser = "LOCAL SERVICE" then strUser=""

if strUser = "NETWORK SERVICE" then strUser=""

'if strUser = "ADMINISTRATOR" then strUser=""

if strUser <> "" then

on error resume next

objShell.Run "%comspec% /c reg delete HKU\" & objSubkey &  "\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\{F4E57C4B-2036-45F0-A9AB-443BCFE33D9F}\Count" & " /f",0,true

Wscript.Sleep 1000

end if

Next

' Clear Session

objShell = ""
strComputer = ""
objWMIService = ""
objRegistry = ""
strKeyPath = ""
strValueName = ""
strSubPath = ""
objAccount = ""
objSubkey = ""
arrSubkeys = ""
strValue = ""
strUser = ""

WScript.Quit(0)

Pascal, C++, JavaScript, PowerShell, C# – Return Prime Numbers

email me

Return prime numbers from 1-100 in different programming languages. All written and tested by me.

Prime Numbers

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

 

Pascal

program OptimusPrime;

{set our constant--this is max number}
const
maxNumber=100;

{set variables--both are integers}
var
x, y:integer;

{set number range to scan}
begin
for x := 2 to maxNumber do
begin
for y := 2 to x do
if (x mod y)=0 then
{break if not prime}
break;
{display prime}
if(y = x) then
write(x, ' ');
end;
end.

Online Pascal compiler

 

C++

#include <iostream>
#include <string>
#include <vector>

int main()
{
// max number to extract primes
int maxNumber = 100;

//set up array
std::vector<int> OptimusPrime = { 2 };
// start number, then increment
for (int x = 2; x <= maxNumber; ++x) 
for (int y = 2; y < x; ++y) {
if (x % y == 0)
break;
if (y == x - 1)
// move to new element
OptimusPrime.push_back(x);
}

// outputs prime num with space
for (int z: OptimusPrime)
std::cout << z << ' ';
return 0;
}

Online C++ compiler

 

JavaScript

var maxNumber = 100;

// run function
OptimusPrime(maxNumber);

// interates through specified number
function OptimusPrime(number) {
var array = [2];
for ( var i = 3; i < number; i+=2 ) {
if ( CheckPrime(i) ) {
//push element
array.push(i);
}
}
// output whole array
document.write(array);
}

// checks if input is prime
function CheckPrime(input) {
for ( var i = 2; i < input; i++ ) {
if ( input % i === 0 ) {
return false;
}
}
return true;
}

Online JavaScript editor

 

PowerShell

Clear-Host
 
$maxNumber = 100
$counter = 0
$intInput = ''
$intDivisor = ''
$boolPrime = ''

# cycle through range 
2..$maxNumber | foreach {
 
    # set input to number in range
    $intInput = $_

    # perform calculation for divisor
    $intDivisor = [math]::Sqrt($intInput)
    $boolPrime = $true
 
    # compare divisor with zero
    2..$intDivisor | foreach {        
        
        if ($intInput % $_ -eq 0) {
        
            $boolPrime = $false
        }
    }
 
    # if prime true, output to screen
    If ($boolPrime) {
        
        Write-Host -NoNewline  $intInput.ToString().PadLeft(3)
        
        # step counter
        $counter++
        
        If ($counter % 10 -eq 0) {            
        }
    }
 
}
 
# clear session
 
$maxNumber = ''
$counter = ''
$intInput = ''
$intDivisor = ''
$boolPrime = ''
 
Write-Host ""
Write-Host ""

Online PowerShell editor

 

C#

// created in Visual Studio 2017, 15.3.2

using System;

namespace Primes
{
    class OptimusPrime
    {
        static void Main(string[] args)
        {
            // set max value
            int maxNumber = 100;

            // default value
            bool Prime = true;            

            for (int x = 2; x <= maxNumber; x++)
            {
                Prime = true;

                for (int y = 2; y <= maxNumber; y++)
                {
                    // Perform calculation for divisor and compare with zero
                    if (x != y && x % y == 0)
                    {
                        Prime = false;
                        break;
                    }
                }
                
                // if prime true, output to console
                if (Prime)                {
                    
                    Console.Write("  " + x);
                }                
            }

            // wait for key press
            Console.ReadKey();
        }
    }
}

Online C# compiler

 

Fortran

see http://eddiejackson.net/wp/?p=20363

Online Fortran compiler

 

JAVA

see: http://eddiejackson.net/wp/?p=18617

 

Notes

Learn more, Pascal language

Learn more, Fortran language

Windows 10 – Wake Timers – Wake on LAN – WoL

email me

Enable or Disable Allow Wake Timers

Wake on LAN not working after a Windows upgrade? Windows 10 broke your WOL solution?

Try this

powercfg /SETACVALUEINDEX SCHEME_CURRENT 238c9fa8-0aad-41ed-83f4-97be242c8f20 bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d 1

That changes the Allow wake timers from Important Wake Timers Only to Enabled. Thanks, Microsoft, for that challenge.

 

All Wake Timers

On battery: Disabled
powercfg /SETDCVALUEINDEX SCHEME_CURRENT 238c9fa8-0aad-41ed-83f4-97be242c8f20 bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d 0

On battery: Enabled – default
powercfg /SETDCVALUEINDEX SCHEME_CURRENT 238c9fa8-0aad-41ed-83f4-97be242c8f20 bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d 1

On battery: Important Wake Timers Only
powercfg /SETDCVALUEINDEX SCHEME_CURRENT 238c9fa8-0aad-41ed-83f4-97be242c8f20 bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d 2

Plugged in: Disabled
powercfg /SETACVALUEINDEX SCHEME_CURRENT 238c9fa8-0aad-41ed-83f4-97be242c8f20 bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d 0

Plugged in: Enabled – default
powercfg /SETACVALUEINDEX SCHEME_CURRENT 238c9fa8-0aad-41ed-83f4-97be242c8f20 bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d 1

Plugged in: Important Wake Timers Only
powercfg /SETACVALUEINDEX SCHEME_CURRENT 238c9fa8-0aad-41ed-83f4-97be242c8f20 bd3b718a-0680-4d9d-8ab2-e1d2b4ac806d 2

 

Notes

Pay attention to the Turn on fast startup as well. You may need to uncheck this.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Power\HiberbootEnabled 0

powercfg -h off

PowerShell – Encoding a Password

email me

Simple Encoding

Clear-Host
write-host ""

[string]$Password = "LetMeIn99$"
 
$EncodedPassword = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Password))
 
write-host "Encoded Password: " $EncodedPassword

write-host ""

 

Simple Decoding

$DecodedPassword = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($EncodedPassword))
 
write-host "Decoded Password: " $DecodedPassword
write-host ""
write-host ""

 

More Advanced Example

Clear-Host

# PART1
# THIS WORKS TO CREATE UNIQUENESS TO THE SECURESTRING
# IT IS CRITICAL THE KEY IS STORED IN A SECURE LOCATION OR
# COMPILED IN A MANNER THAT IS SECURE
# https://docs.microsoft.com/en-us/azure/storage/common/customer-managed-keys-configure-key-vault
[Byte[]] $Key = (2, 1, 5, 3, 2, 8, 4, 1, 7, 16, 9, 2, 13, 3, 12, 15)

$EncryptedPassword = "LetMeIntoTheComputer777$" | ConvertTo-SecureString -AsPlainText -Force

# PART2
$Password = "76492d1116743f0423413b16050a5345MgB8ADQAVgBzADQAdABCAEYAKwBlAHEAcgBqAE4AMQB2AGoAYQB0AHYAWgBOAGcAPQA9AHwAYwBiAGMAOABkADAAMQAxAGUAMgA5ADkAZABmAGQANAA4AGEAMgA4AGUAYwA2ADYAOQA3ADgAMwA0AD
gAMQAxADgAZgBhADEAOAA2ADIANgAwADUAOABiAGYAOQBiADEANwAyADMAYgAxAGYAYQA4ADkAYwAyADgAOAA5ADEAYgA5ADUAYgBmAGQAYQAxAGYAOQAxAGEANABhAGYAMwAyADYAZgA4ADQAYgA3AGQAYQAyAGMAZQBiADIAYQBmAGYANgA5
ADkAMgBkAGEAZAAzADAAZgA1AGQAYQAxADQANwBlAGEAZgA3ADEAZABjADYAOQA3ADEANQAyADQAMgAyAA=="

$SecurePassword = ConvertTo-SecureString $Password -key $Key

$SecurePassword | ConvertFrom-SecureString -key $Key

$UserAccount = Get-LocalUser -Name "Administrator"

$UserAccount | Set-LocalUser -Password $SecurePassword