Convert Windows Server Evaluation to Standard/Datacenter Edition

Problem:
You want to convert your windows server evaluation edition to a standard or datacenter edition.

Solution:
Before we can activate the server via KMS or MAC we need to convert the evaluation edition into an standard or datacenter.

Check the current Edition

DISM /online /Get-CurrentEdition

Here you see the server edition. If it is an ServerXXXEval you must convert the server edition into standard or datacenter



Check the possible target editions

To check the possible target edition, you can execute the next command:

DISM /online /Get-TargetEditions



Convert the eval to standard or datacenter edition

ATTENTION: The next step will need an intermediate reboot of the server!!
Now you can convert your evaluation edition to the target edition with the command below:

Standard:
DISM /online /Set-Edition:ServerStandard /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula

Datacenter
DISM /online /Set-Edition:ServerDatacenter /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula



For the product key please use the generic volume license keys from the table below. With this keys you can also activate the server via KMS. If you have MAC Keys please use this keys for converting.

Server 2022 Standard VDYBN-27WPP-V4HQT-9VMD4-VMK7H
Server 2022 Datacenter WX4NM-KYWYW-QJJR4-XV3QB-6VM33
Server 2019 Standard N69G4-B89J2-4G8F4-WWYCC-J464C
Server 2019 Datacenter WMDGN-G9PQG-XVVXX-R3X43-63DFG
Server 2016 Standard WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY
Server 2016 Datacenter CB7KF-BWN84-R7R2Y-793K2-8XDDG

VirtualBox: Set DmiSystemVendor Installation ROK Datenträger Windows

Problem:
Wir wollten einen physikalischen Server inkl. Applikation auf einen virtuell Server umziehen und from scratch neu installieren (kein P2V). Hierzu mussten wir die originalen Installationsmedien des Herstellers verwenden, da es sich um eine ROK-Lizenzen gehandelt. Bei der Installation in einer VM unter VirtualBox kam der Hinweis, dass das installationsmedium Vendor branded ist und die Installation bricht ab.

Lösung:
Man kann der VM unter VirtualBox einen Vendor BIOS Tag mitgeben, damit die Installation funktioniert. Das konnten wir bei Fujitsu und HP sauber abbilden.

Folgende Befehle haben hier den Vendor im BIOS gesetzt:

Fujitsu
VBoxManage setextradata "Analysis" "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVendor"      "FUJITSU"
VBoxManage setextradata "Analysis" "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVendor"        "FUJITSU // Phoenix Technologies Ltd."

HP
VBoxManage setextradata "VM Name" "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVendor" "HP"
VBoxManage setextradata "VM Name" "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVendor" "HP"




Ein überblick aller Befehle findet man hier: Configuring the BIOS DMI Information

Powershell: Unpin App from Taskbar

Problem:
Ich habe nach einer Möglichkeit gesucht den Internet Explorer von der Taskleiste auf unseren Terminalservern zu entfernen und den Edge dafür zu setzen. Die Ernüchterung war, dass Unpin funktioniert, aber Pin nicht mehr unterstützt wird. Somit konnte ich zumindest den Internet Explorer von der Taskleiste entfernen.

Unpin App from Tasskbar

Deutsches OS
$appname = "Internet Explorer"
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Von Taskleiste lösen'} | %{$_.DoIt(); $exec = $true}


Englisches OS
$appname = "Internet Explorer"
((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt(); $exec = $true}

Printserver Migration Part #4: Import Printer and Settings

Ich stelle hier ein paar Skripte zur Verfügung, welche einem die Migration eines Printservers etwas vereinfachten. Selbstverständlich kann man das auch mir Printmig oder anderen Tools durchführen. Ich wollte meinen neuen Printserver from scratch neu installieren, daher der etwas andere Weg. Die Migration wird in vier Teile erfolgen:

Part #1: Export TCP- und LPR-Ports
Part #2: Export Drucker mit allen Settings in eine XML-Datei
Part #3: Import TCP- und LPR-Ports
Part #4: Import aller Drucker mit allen Settings

WICHTIG: Vor dem nächsten schritt müssen erst alle nötigen Druckertreiber installiert werden. Sollte sich der Name oder die Version der Druckertreiber ändern, dann müssen diese vorher in der exportierten CSV-Datei angepasst werden.
Nachdem die Druckertreiber installiert wurden, kann man mit einem Get-PrinterDriver dir Druckertreiber anzeigen lassen. Hier findet man unter dem Punkt "Name" den Namen, welcher in der CSV entsprechend ausgetauscht werden muss. Sollte der Name nicht übereinstimmen, dann erhält man einen Fehler bei der Erstellung des Druckers, dass der Treiber nicht gefunden wurde. Nachdem dir Treiber installiert sind und die CSV ggf. angepasst wurde, können dir Drucker nun per Powershell erstellt werden (inkl. Konfiguration aus der XML).
Hinweis: Es hat sich gezeigt, dass Etikettendrucker nochmals gesondert geprüft werden müssen, da manche Informationen nicht im Windows-Treiber gespeichert wird (Druckkopf-Konfiguration).
Außerdem benötigt die Erstellung von Druckern, welche offline sind, ca. 1 Minute (TCP-Timeout).

Create-Printers_from_CSV.ps1
<# 
.NAME
    Create-Printers_from_CSV.ps1

.AUTHOR
    Ralf Entner

.SYNOPSIS
    Script creates all printers from a csv file. Config will be restored by import xml file.

.DESCRIPTION 
    Script creates all printers with all settings from a csv and xml file.
    With the testmode $true you can run the script without any changes. It will only show whatif
    A log file will be created
 
.NOTES 
    You have to install the printer drivers on the system before you run the script.
    printer driver names must be changed in the csv file if it differs from the original names.
    If the pritner is offline the creation will take approximal 1 mintue.

.COMPONENT 
    No powershell modules needed

.LINK 
    No Links
 
.Parameter ParameterName 
    $CSVPath - Define export path of the csv file
    $Testmode - Defines testmode: $true = test | $false = live
    $Logpath - Path for log file
#>

#Testmode ($true = active | $false = inactive)
$Testmode = $false

# CSV Import path
$CSVPath = "C:\tgswinv\Printmig\Printers.csv"

# XML import path
$XMLPath = "C:\tgswinv\Printmig\"

# Log File
$Logpath = "C:\tgswinv\Printmig\CreatePrinter.log"

#Start transciption 
Start-Transcript -Path $Logpath -Append

# Import Printers
$Printers = Import-Csv -Path $CSVPath -Delimiter ";"



foreach($Printer in $Printers){

    if(!(Get-Printer -Name $Printer.Name -ErrorAction SilentlyContinue))
    {
        Write-Host "Generating new pritner" $Printer.Name -ForegroundColor Green
        # If port not exists create a new one with parameters from csv import
        Add-Printer -Name $Printer.Name -PortName $Printer.Portname -DriverName $Printer.Drivername -Location $Printer.Location -Comment $Printer.Comment -WhatIf:$Testmode
        Start-Sleep -Seconds 2

        Write-Host "Import printer configuration from xml" $Printer.Name -ForegroundColor Green
        # If port not exists create a new one with parameters from csv import
        # Generate printer configuration path to xml file
        $XMLConfigFile = $XMLPath + $Printer.Name + ".xml"
        # Import printer configuration from xml file
        $XMLConfig = Get-Content $XMLConfigFile | Out-String
        # Set printer configuration from xml file
        Set-PrintConfiguration -PrinterName $Printer.Name -PrintTicketXml $XMLConfig -WhatIf:$Testmode
    }
}

Stop-Transcript


Printserver Migration Part #3: Import TCP- und LPR-Ports

Ich stelle hier ein paar Skripte zur Verfügung, welche einem die Migration eines Printservers etwas vereinfachten. Selbstverständlich kann man das auch mir Printmig oder anderen Tools durchführen. Ich wollte meinen neuen Printserver from scratch neu installieren, daher der etwas andere Weg. Die Migration wird in vier Teile erfolgen:

Part #1: Export TCP- und LPR-Ports
Part #2: Export Drucker mit allen Settings in eine XML-Datei
Part #3: Import TCP- und LPR-Ports
Part #4: Import aller Drucker mit allen Settings

Part #3: Import TCP- und LPR-Ports
Jetzt können wir die TCP- und LPR-Ports auf dem neuen Printserver erstellen lassen.
Auch hier gibt es wieder zwei Skripte, da TCP-Ports anders erzeugt werden als LPD-Ports.
ACHTUNG: Vor der Erstellung der LPR-Ports muss der LPD-Service erst über den Servermanager installiert werden, damit der LPR-Porttype zur Verfügung steht.
TIPP: Sollten die Namen oder die IPs der Ports geändert werden, dann bitte vorher in der CSV anpassen!

Create-Printerports_TCP_from_CSV.ps1
<# 
.NAME
    Create-Printerports_TCP_from_CSV.ps1

.AUTHOR
    Ralf Entner

.SYNOPSIS
    Script creates all TCP Printer Ports from a csv file.

.DESCRIPTION 
    Script creates all TCP Printer Ports with all settings from a csv file. In the csv file there are address, port number and smtp settings.
 
.NOTES 
    With the testmode $true you can run the script without any changes. It will only show whatif

.COMPONENT 
    No powershell modules needed

.LINK 
    No Links
 
.Parameter ParameterName 
    $CSVPath - Define import path of the csv file
    $Testmode - Defines testmode: $true = test | $false = live
#>

$CSVPath = "C:\tgswinv\Printmig\PortsTCP.csv"
$Testmode = $false

# Import CSV with Port Informations
$PrinterPorts = Import-CSV -Path $CSVPath -Delimiter ";"

# Loop through 
Foreach($Port in $PrinterPorts){

Write-Host "Creating Printerport $Name"

# Check if Printerport already exists
if(!(Get-PrinterPort -Name $Port.Name -ErrorAction SilentlyContinue))
    {
        Add-PrinterPort -Name $Port.Name -PrinterHostAddress $Port.PrinterHostAddress -PortNumber $Port.Portnumber -SNMPCommunity $Port.SNMPCommunity -SNMP $true -WhatIf:$Testmode
    }
}

Create-Printerports_LPR_from_CSV.ps1
<# 
.NAME
    Create-Printerports_LPR_from_CSV.ps1

.AUTHOR
    Ralf Entner

.SYNOPSIS
    Script creates all LPR Printer Ports from a csv file.

.DESCRIPTION 
    Script creates all LPR Printer Ports with all settings from a csv file.
    In the csv file there are name, protocol, port nubmer and printer host address.
 
.NOTES 
    With the testmode $true you can run the script without any changes. It will only show whatif

.COMPONENT 
    ATTENTION: You have to install the LPR printer monitor before you add the ports!
    No powershell modules needed

.LINK 
    No Links
 
.Parameter ParameterName 
    $CSVPath - Define import path of the csv file
    $Testmode - Defines testmode: $true = test | $false = live
#>

$CSVPath = "C:\tgswinv\Printmig\PortsLPR.csv"
$Testmode = $false

# Import CSV with Port Informations
$PrinterPorts = Import-CSV -Path $CSVPath -Delimiter ";"

# Loop through 
Foreach($Port in $PrinterPorts){

Write-Host "Creating Printerport "$Port.Name

# Check if Printerport already exists
if(!(Get-PrinterPort -Name $Port.Name -ErrorAction SilentlyContinue))
    {
        #Add-PrinterPort -Name $Port.PrinterName -PrinterHostAddress $Port.hostname -WhatIf:$Testmode
        Add-PrinterPort -PrinterName $Port.Printername -HostName $port.Hostname   -WhatIf:$Testmode
    }
}



Printserver Migration Part #2: Export Printer and Printer Settings

Ich stelle hier ein paar Skripte zur Verfügung, welche einem die Migration eines Printservers etwas vereinfachten. Selbstverständlich kann man das auch mir Printmig oder anderen Tools durchführen. Ich wollte meinen neuen Printserver from scratch neu installieren, daher der etwas andere Weg. Die Migration wird in vier Teile erfolgen:

Part #1: Export TCP- und LPR-Ports
Part #2: Export Drucker mit allen Settings in eine XML-Datei
Part #3: Import TCP- und LPR-Ports
Part #4: Import aller Drucker mit allen Settings

Part #2: Export Drucker mit allen Settings in eine XML-Datei
Mit dem nachfolgenden Skript erfolgt der Export aller installierten Drucker, welche Netzwerkdrucker sind. Es wird eine CSV mit den grundlegenden Druckerinformationen erstellt. Außerdem wird für jeden Drucker die Konfiguration in eine XML-Datei exportiert, welche die komplette Konfiguration der Schächte und Papierquellen etc. enthält. Mit diesen Informationen können später die Drucker vollständig auf dem neuen Server wiederhergestellt werden.

Export-Printer_and_Printerconfiguration.ps1
<# 
.NAME
    Export-Printer_and_Printerconfiguration.ps1

.AUTHOR
    Ralf Entner

.SYNOPSIS
    Script exports all network printers and printer settings.

.DESCRIPTION 
    Script exports all network Printers with all settings to a single csv file.
    The printer configurations are also exported in a xml file for each printer name (printername.xml)
    The export includes name, shared name, port name, driver name, location, comment und publishing information.

.NOTES 
    The script exports only network printers.

.COMPONENT 
    No powershell modules needed

.LINK 
    No Links
 
.Parameter ParameterName 
    $CSVPath - Define export path of the csv file
    $XMLPath - Define export path of xml file for each printer configuration
#>
# Export CSV path
$CSVPath = "C:\Printmig\Printers.csv"
$XMLPath = "C:\Printmig\"

# Get all printers and informtaions
$Printers = Get-Printer | ?{$_.PortName -ne "PORTPROMPT:"} | select Name, ShareName, PortName, DriverName, Location, Comment, Published, Shared

# Export Printers to csv
$Printers | Export-Csv -Path $CSVPath -Delimiter ";" -Encoding UTF8 -NoTypeInformation

Foreach ($Printer in $Printers){

    #Exportpaht for XML

    $XMLFilePath = $XMLPath + $Printer.Name + ".xml"

    # Export PrinterConfiguration to XML
    $GPC = get-printconfiguration -PrinterName $Printer.Name
    $GPC.PrintTicketXML | out-file $XMLFilePath
}

“Das einzig sichere System müsste ausgeschaltet, in einem versiegelten und von Stahlbeton ummantelten Raum und von bewaffneten Schutztruppen umstellt sein.”
Gene Spafford (Sicherheitsexperte)