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 / Remove-AllMediaFromScVirtualMachinesV2.ps1
Created December 3, 2021 10:14
This small snippet removes mounted media from all SCVMM VMs. This will also *get* drives of snapshots, which cannot be processed.
Get-SCVirtualDVDDrive -All | Where-Object {$_.Connection -ne 'None' -and $_.Connection -ne $null} | Set-SCVirtualDVDDrive -NoMedia
@norman-bauer
norman-bauer / GermanTimezone.cmd
Created August 26, 2021 09:48
Changes Windows timezone to Western Europe Standard Time with DST.
tzutil /s "W. Europe Standard Time"
@norman-bauer
norman-bauer / Remove-AllMediaFromScVirtualMachines.ps1
Created July 17, 2021 08:19
This small snippet removes mounted media from all SCVMM VMs.
Get-SCVirtualMachine | Foreach-Object {
$vm = $_;
$dvd = Get-SCVirtualDVDDrive -VM $vm;
if ($dvd.Connection -ne 'None' -and $dvd.Connection -ne $null) {
Set-SCVirtualDVDDrive -VirtualDVDDrive $dvd -NoMedia
}
}
@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
$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