Scripts/Handig.ps1


Start-Process cleanmgr -ArgumentList "/sagerun:1 /VeryLowDisk /AUTOCLEAN"

Get-ChildItem $env:TEMP | Remove-Item -Recurse -Force -ea 0


Get-UserProfiles | Where-Object { $_.LastUseTime -lt (Get-Date).AddDays(-180) } | Remove-CimInstance


New-InboxRule -FromAddressContainsWords support@henkie.nl -MoveToFolder someone@somewhere.com:\Inbox\Automail -Name "support@henkie.nl"



$FilePath = ".\wiki-logo-wit.png"

$Base64 = [Convert]::ToBase64String((Get-Content $FilePath -AsByteStream))
$Base64
$HTML = "<img src=`"data:image/png; base64, $($Base64)`" />"
$HTML
$HTML | clip

$OutFilePath = "C:\Temp\test.png"
$Image = [Drawing.Bitmap]::FromStream([IO.MemoryStream][Convert]::FromBase64String($Base))
$Image.Save($OutFilePath)



[System.Environment]::SetEnvironmentVariable("DockerFolder", "$($env:Onedrive)\Docker", "Machine")



# Remote wipe

$namespaceName = "root\cimv2\mdm\dmmap"
$className = "MDM_RemoteWipe"
$methodName = "doWipeMethod"

$session = New-CimSession

$params = New-Object Microsoft.Management.Infrastructure.CimMethodParametersCollection
$param = [Microsoft.Management.Infrastructure.CimMethodParameter]::Create("param", "", "String", "In")
$params.Add($param)

$instance = Get-CimInstance -Namespace $namespaceName -ClassName $className -Filter "ParentID='./Vendor/MSFT' and InstanceID='RemoteWipe'"

if ($WeetJeHetAbsoluutZeker) {
    $session.InvokeMethod($namespaceName, $instance, $methodName, $params)
}



# Detect onbekende devices / missende drivers
Get-PnpDevice | Where-Object Status -NotMatch "OK|Unknown" | Format-List


# Powersettings
powercfg /batteryreport


# Defender Anti-virus


Get-MpPreference
Get-MpPreference | Select-Object -ExpandProperty exclusionpath
Add-MpPreference -ExclusionPath 'C:\Temp\test'
Remove-MpPreference -ExclusionPath 'C:\Temp\test'





$TaskAction = New-ScheduledTaskAction -Execute "tsdiscon.exe"
# New-ScheduledTaskPrincipal
$TaskTrigger = New-ScheduledTaskTrigger -AtLogOn
Register-ScheduledTask -TaskName "Lock at logon" -Action $TaskAction -Trigger $TaskTrigger



function New-Shortcut {
    param (
        [parameter(mandatory = $true)][string]$ShortcutLocation,
        [parameter(mandatory = $true)][string]$ShortcutTarget,
        [string]$Arguments,
        [string]$IconLocation
    )

    $shortcutTargetParent = Split-Path $ShortcutTarget -Parent

    $WshShell = New-Object -ComObject WScript.Shell

    $Shortcut = $WshShell.CreateShortcut($ShortcutLocation)
    if ($Arguments) {
        $Shortcut.Arguments = $Arguments
    }
    $Shortcut.TargetPath = $ShortcutTarget
    if ($shortcutTargetParent) {
        $Shortcut.WorkingDirectory = $shortcutTargetParent
    }
    if ($IconLocation) {
        $Shortcut.IconLocation = $IconLocation
    }
    $Shortcut.Save()

}