Skip to content

Instantly share code, notes, and snippets.

View norman-bauer's full-sized avatar

Norman Bauer norman-bauer

View GitHub Profile
@norman-bauer
norman-bauer / Get-AllScVirtualMachinesWithMediaInDrive.ps1
Last active July 17, 2021 08:16
This small snippet lists all SCVMM VMs (with Name, Host, Connection type and Iso name) that have media attached to their DVD drives.
Get-SCVirtualMachine | Foreach-Object {
$vm = $_;
$dvd = Get-SCVirtualDVDDrive -VM $vm;
if ($dvd.Connection -ne 'None' -and $dvd.Connection -ne $null) {
Write-Host $vm.Name $vm.VMHost.Name $dvd.Connection $dvd.Iso
}
}
@norman-bauer
norman-bauer / RemoveLanguagePack.cmd
Last active February 25, 2021 13:06
In case your IT department deploys updates and they'll reinstall language packs and you forgot how to get rid of them again... Or open gpedit.msc, navigate to Computer Configuration, Administrative Templates, Control Panel, Regional and Language Options - enable "Restricts the UI language Windows uses for all logged users" and set it to English.
Dism /Online /Get-Packages
Dism /Online /Remove-Package /PackageName:Microsoft-Windows-Client-LanguagePack-Package~31bf3856ad364e35~amd64~de-DE~10.0.18362.1198
@norman-bauer
norman-bauer / Unify-DHCPScopeSettingsInDomain.ps1
Created October 29, 2020 09:09
This script updates all scopes of all authorized DHCP servers in a domain to use specified dns update credentials, to always update dns records and to set maximum lease duration
$dhcpServers = Get-DhcpServerInDC
$Credential = Get-Credential
$days = Read-Host "Maximum lease duration in days (scopes with longer periods are set to this value)"
$timespan = New-TimeSpan -Days $days
foreach ($dhcpServer in $dhcpServers) {
Write-Host $dhcpServer.DnsName
Set-DhcpServerDnsCredential -Credential $Credential -ComputerName $dhcpServer.DnsName
Write-Host " DNS Update credentials set"
$scopes = Get-DhcpServerv4Scope -ComputerName $dhcpServer.DnsName
$bootevents = Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Diagnostics-Performance/Operational"; id=100}
$bootevent = [xml]$bootevents[0].ToXml()
$bootevent.Event.EventData.Data
$shutdownevents = Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Diagnostics-Performance/Operational"; id=200}
$shutdownevent = [xml]$shutdownevents[0].ToXml()
$shutdownevent.Event.EventData.Data
$mySiteWebapplicationUrl = "https://mysite.normanbauer.com/"
#current Url of your mySite website
$mySiteOldUrlValue = "http://mysitetest:80/"
#former Url where your pictures do not reside any more
$mySiteNewUrlValue = "https://mysite.normanbauer.com:443/"
#current Url where your images can be found now
$mySite = Get-SPSite $mySiteWebapplicationUrl
$schemaContext = Get-ADRootDSE | %{$_.schemaNamingContext}
Foreach ($dc in ([System.DirectoryServices.ActiveDirectory.DomainController]::findall(
(new-object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain",$env:USERDNSDOMAIN)))) |
%{$_.name})
{
$path = ‘LDAP://’ + $dc + ‘/’ + $schemaContext
$Object = [adsi]$path
$dc + ‘ ‘ + $Object.objectversion
}
import-module ActiveDirectory
function RestoreComputer($computername)
{
If ($computername.substring($computername.length – 1, 1) -ne ‘$’)
{
$computername += ‘$’
}
$existing = Get-ADObject -Filter {sAMAccountName -eq $computername}
Set objXmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
objXmlHttp.setOption 2, 13056 'http://msdn.microsoft.com/en-us/library/ms763811(v=VS.85).aspx
objXmlHttp.open "GET", "https://urlwithcertificateerror", False
objXmlHttp.send
wscript.echo objXmlHttp.responseText
Set objXmlHttp = Nothing
@norman-bauer
norman-bauer / BasicEWSSoapRequest.xml
Created August 23, 2019 09:03
This is an example on how to connect to Exchange EWS using xml and vbs.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" Traversal="Shallow">
<ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
</ItemShape>
<ParentFolderIds>
<t:DistinguishedFolderId Id="deleteditems"/>
</ParentFolderIds>
@norman-bauer
norman-bauer / Get-BitlockerInformation.vbs
Last active August 23, 2019 08:54
Shows information on Bitlocker encrypted volumes. Run from an elevated command prompt.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume",,48)
Dim arEncryptionMethod
arEncryptionMethod = Array("None", "AES 128 With Diffuser", "AES 256 With Diffuser", "AES 128", "AES 256", "HARDWARE ENCRYPTION", "XTS AES 128", "XTS AES 256")
Dim arProtectionStatus
arProtectionStatus = Array("Protection Off", "Protection On", "Protection Unknown")