Benutzer-Werkzeuge

Webseiten-Werkzeuge


know-how:windows

Dies ist eine alte Version des Dokuments!


Inhaltsverzeichnis

reportLegacyNotebooks.php

  • Analog zu reportRiskUsers.php
  • Finde alle Notebooks zu denen es keine User mehr gibt d.h. User die den Standort verlassen haben
<?php

$server = "ldaps://FQDN_AD_SERVER:636";
//domain user to connect to LDAP
$user = "STANDARD_USER_AD";
//user password
$passwd = "PASSWD";

$dn = "DINSTINGUISHED_NAME_USERS_OU";

$errUser=0;
$countAll=0;
$okUser=0;

$intuneDevices=getIntuneDevices();

if(!is_array($intuneDevices))
{
	die("Cannot read intuneDevices");
}

echo "All notebooks that don't have a user anymore: "."\n";

$countAll=count($intuneDevices);

         for ($k=0; $k<count($intuneDevices) ; $k++)
         {


		         $ds=ldap_connect($server);
                         $r=ldap_bind($ds, $user , $passwd);

                         $sr=ldap_search($ds, $dn, "(|(proxyAddresses=smtp:".$intuneDevices[$k]["userPrincipalName"].")(userprincipalname=".$intuneDevices[$k]["userPrincipalName"]."))", array(0=>"UserPrincipalName",1=>"proxyAddresses"));

			 $data = ldap_get_entries($ds, $sr);


			 //print_r($data);
			 //exit;

                        if($data["count"]===0)
                        {

                                echo "FAIL - Device: ".$intuneDevices[$k]["deviceName"]." / ManagedName: ".$intuneDevices[$k]["managedDeviceName"]." has no user Account anymore: ".$intuneDevices[$k]["userPrincipalName"]."\n";

				$errUser++;

                        }
                        else
                        {
                                $okUser++;
			}


			ldap_close($ds);

	}


echo "Summary:\n";
echo "All notebook objects found: ".$countAll."\n";
echo "All notebook objects ok: ".$okUser."\n";
echo "Consistency integrity: ";
printf("%.2f \n",(($okUser/$countAll)*100));
echo "Errors Notebook/User count: ".$errUser."\n";
echo "OU's that i looked for :\n";
print_r($dn);

echo "\n";




function getIntuneDevices()
{

$curl_token= curl_init();
//Azure AD Administration: Tenant properties / Tenant ID: 123-123-123
//
// Details: https://docs.microsoft.com/en-us/graph/auth-v2-service
curl_setopt($curl_token,CURLOPT_URL, "https://login.microsoftonline.com/123-123-123/oauth2/v2.0/token");
curl_setopt($curl_token,CURLOPT_HEADER,0);
curl_setopt($curl_token,CURLOPT_POST,1);
curl_setopt($curl_token,CURLOPT_POSTFIELDS,"client_id=123-123-123&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=SHARED_SECRET_CREDENTIALS&grant_type=client_credentials");
curl_setopt($curl_token,CURLOPT_RETURNTRANSFER,1);



$json_response=curl_exec($curl_token) or die("Cannot exec url request");

curl_close($curl_token);


$access_array=json_decode($json_response,true) or die("Cannot decode json");

//print_r($access_array);


if(!isset($access_array["access_token"]))
{
	die("Cannot receive access_token");
}



$curl_token= curl_init();


// https://docs.microsoft.com/en-us/graph/api/intune-devices-manageddevice-list?view=graph-rest-1.0
//
curl_setopt($curl_token,CURLOPT_URL, "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices");
curl_setopt($curl_token,CURLOPT_HEADER,0);
curl_setopt($curl_token,CURLOPT_POST,0);
curl_setopt($curl_token,CURLOPT_HTTPHEADER,array("Authorization: Bearer ".$access_array["access_token"]));
curl_setopt($curl_token,CURLOPT_RETURNTRANSFER,1);

$json_response=curl_exec($curl_token) or die("Cannot exec url request");

curl_close($curl_token);

//print_r($json_response);

$intune_array=json_decode($json_response,true) or die("Cannot decode json");

$intune_array=$intune_array["value"];

return $intune_array;





}


?>

reportMissingNotebooks.php

  • Analog zu reportRiskUsers.php
  • Finde alle Schüler der 1. und 2. Klasse die kein Notebook enrolled haben / zB: als Cron Job
  • Im LDAP Attribut Department befindet sich die Klassenbzeichnung zB: 2E
<?php

$server = "ldaps://FQDN_AD_SERVER:636";
//domain user to connect to LDAP
$user = "STANDARD_USER@DOMAIN_AD";
//user password
$passwd = "PASSWD";

$dn = array(0=>"OU_PATH_ALL_PUPILS");

$classesRegex="/^(1|2).*$/";


$search="(objectClass=user)";


$errUser=0;
$countAll=0;
$okUser=0;

$intuneDevices=getIntuneDevices();

if(!is_array($intuneDevices))
{
	die("Cannot read intuneDevices");
}

for ($j=0; $j<count($dn); $j++)
{
        $ds=ldap_connect($server);
       $r=ldap_bind($ds, $user , $passwd);

	$sr=ldap_search($ds, $dn[$j], $search, array(0=>"UserPrincipalName",1=>"distinguishedName",2=>"department",3=>"description"));

	$data = ldap_get_entries($ds, $sr);    
       


	for ($i=0; $i<$data["count"]; $i++) 
	{
	         
		//debugging is phun
		//echo ($data[$i]["distinguishedname"][0])."\n";
		//echo ($data[$i]["userprincipalname"][0])."\n";
		//echo ($data[$i]["department"][0])."\n";

		$distinguishedName=strtolower($data[$i]["distinguishedname"][0]);
		$userPrincipalName=strtolower($data[$i]["userprincipalname"][0]);
		$department=strtolower(@$data[$i]["department"][0]);


		$regMatch=preg_match($classesRegex,$department);
		
		if($regMatch !== 0)
		{

		    if(!isset($data[$i]["department"][0]))
                    {
                        echo "FAIL - User: ".$distinguishedName." has no Department"."\n";
                        $errUser++;
                    }


			$countAll++;
			//Debugging is phun
			//echo $distinguishedName."\n";
			//echo $department."\n";

			$notFound=true;

			for ($j=0; $j<count($intuneDevices) && $notFound; $j++)
			{
				$devicePrincipalName=strtolower($intuneDevices[$j]["userPrincipalName"]);

				if($userPrincipalName == $devicePrincipalName )
				{
					$notFound=false;

				}


                       
			}


			if($notFound)
			{

				echo "FAIL - User: ".$distinguishedName." has no enrolled device"."\n";
				$errUser++;

			}
			else
			{
				$okUser++;
			}

			// Device Details: print_r($intuneDevices[--$j]);
		}
               

	}
 // close connection
 ldap_close($ds);
}

echo "Summary:\n";
echo "All user objects found: ".$countAll."\n";
echo "All user objects ok: ".$okUser."\n";
echo "Consistency integrity: ";
printf("%.2f \n",(($okUser/$countAll)*100));
echo "Errors computer count: ".$errUser."\n";
echo "Regex Classroom check: ".$classesRegex."\n";
echo "OU's that i looked for :\n";
print_r($dn);

echo "\n";




function getIntuneDevices()
{

$curl_token= curl_init();
//Azure AD Administration: Tenant properties / Tenant ID: 123-123-123
//
// Details: https://docs.microsoft.com/en-us/graph/auth-v2-service
curl_setopt($curl_token,CURLOPT_URL, "https://login.microsoftonline.com/123-123-123/oauth2/v2.0/token");
curl_setopt($curl_token,CURLOPT_HEADER,0);
curl_setopt($curl_token,CURLOPT_POST,1);
curl_setopt($curl_token,CURLOPT_POSTFIELDS,"client_id=foo-foo-foo&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=CLIENT_SECRET&grant_type=client_credentials");
curl_setopt($curl_token,CURLOPT_RETURNTRANSFER,1);



$json_response=curl_exec($curl_token) or die("Cannot exec url request");

curl_close($curl_token);


$access_array=json_decode($json_response,true) or die("Cannot decode json");

//print_r($access_array);


if(!isset($access_array["access_token"]))
{
	die("Cannot receive access_token");
}



$curl_token= curl_init();


// https://docs.microsoft.com/en-us/graph/api/intune-devices-manageddevice-list?view=graph-rest-1.0
//
curl_setopt($curl_token,CURLOPT_URL, "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices");
curl_setopt($curl_token,CURLOPT_HEADER,0);
curl_setopt($curl_token,CURLOPT_POST,0);
curl_setopt($curl_token,CURLOPT_HTTPHEADER,array("Authorization: Bearer ".$access_array["access_token"]));
curl_setopt($curl_token,CURLOPT_RETURNTRANSFER,1);

$json_response=curl_exec($curl_token) or die("Cannot exec url request");

curl_close($curl_token);

//print_r($json_response);

$intune_array=json_decode($json_response,true) or die("Cannot decode json");

$intune_array=$intune_array["value"];

return $intune_array;






}


?>

reportIntuneDevices.php

...
...
Bearer Access Token organisieren wie bei reportRiskUsers.php
...
...



$curl_token= curl_init();


// https://docs.microsoft.com/en-us/graph/api/intune-devices-manageddevice-list?view=graph-rest-1.0
//
curl_setopt($curl_token,CURLOPT_URL, "https://graph.microsoft.com/v1.0/deviceManagement/managedDevices");
curl_setopt($curl_token,CURLOPT_HEADER,0);
curl_setopt($curl_token,CURLOPT_POST,0);
curl_setopt($curl_token,CURLOPT_HTTPHEADER,array("Authorization: Bearer ".$access_array["access_token"]));
curl_setopt($curl_token,CURLOPT_RETURNTRANSFER,1);

$json_response=curl_exec($curl_token) or die("Cannot exec url request");

curl_close($curl_token);

//print_r($json_response);

$intune_array=json_decode($json_response,true) or die("Cannot decode json");

$intune_array=$intune_array["value"];

print_r($intune_array);


/*

    [0] => Array
        (
            [id] => id
            [userId] => id
            [deviceName] => DESKTOP-HXND
            [managedDeviceOwnerType] => personal
            [enrolledDateTime] => 2021-06-28T09:13:53Z
            [lastSyncDateTime] => 2021-07-01T05:23:27Z
            [operatingSystem] => Windows
            [complianceState] => compliant
            [jailBroken] => Unknown
            [managementAgent] => mdm
            [osVersion] => 10.0.14393.0
            [easActivated] => 1
            [easDeviceId] => id
            [easActivationDateTime] => 0001-01-01T00:00:00Z
            [azureADRegistered] => 1
            [deviceEnrollmentType] => userEnrollment
            [activationLockBypassCode] => 
	    [emailAddress] => max.mustermann@mail
	    [azureADDeviceId] => id
            [deviceRegistrationState] => registered
            [deviceCategoryDisplayName] => Unknown
            [isSupervised] => 
            [exchangeLastSuccessfulSyncDateTime] => 0001-01-01T00:00:00Z
            [exchangeAccessState] => none
            [exchangeAccessStateReason] => none
            [remoteAssistanceSessionUrl] => 
            [remoteAssistanceSessionErrorDetails] => 
            [isEncrypted] => 
            [userPrincipalName] => UPN
            [model] => VirtualBox
            [manufacturer] => innotek GmbH
            [imei] => 
            [complianceGracePeriodExpirationDateTime] => 2021-06-30T07:05:43Z
            [serialNumber] => 0
            [phoneNumber] => 
            [androidSecurityPatchLevel] => 
            [userDisplayName] => Name User
            [configurationManagerClientEnabledFeatures] => 
            [wiFiMacAddress] => 
            [deviceHealthAttestationState] => 
            [subscriberCarrier] => 
            [meid] => 
            [totalStorageSpaceInBytes] => 53160706048
            [freeStorageSpaceInBytes] => 38004588544
            [managedDeviceName] => funky name
            [partnerReportedThreatState] => unknown
            [iccid] => 
            [udid] => 
            [notes] => 
            [ethernetMacAddress] => 
            [physicalMemoryInBytes] => 0
            [deviceActionResults] => Array
                (
                )

        )



 */


?>

reportRiskUsers.php

  • Das Skript soll sich automatisiert über die Graph API alle Risk Infos der letzten 24 Stunden holen und die betroffenen User ausgeben
  • Es ist dennoch möglich zuzugreifen über die Microsoft Graph API / Es muss eine App im Azure erstellt werden und die Werte im PHP Skript entsprechend angepasst / Als täglicher Cron Job auf einem Linux Server im Einsatz - wobei stdout per Mail versand wird an administrativen Mail Account :)
<?php


$curl_token= curl_init();
//Azure AD Administration: Tenant properties / Tenant ID: 1245678-89-1011-121314-1516abef
//
// Details: https://docs.microsoft.com/en-us/graph/auth-v2-service 
// Vorher im Azure AD eine App anlegen https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps mit Client Secret d.h. Shared Key 
// API Permissions auf IdentityRiskEvent.Read.All - muss durch Admin "Granted werden" "Grant Admin consent"


//client_id ist "APPLICATION (CLIENT) ID" der App zB: 0815123-0815123-0815123
//client_secret ist Shared Key , der bei Client Secret erstellt wurde 

curl_setopt($curl_token,CURLOPT_URL, "https://login.microsoftonline.com/1245678-89-1011-121314-1516abef/oauth2/v2.0/token");
curl_setopt($curl_token,CURLOPT_HEADER,0);
curl_setopt($curl_token,CURLOPT_POST,1);
curl_setopt($curl_token,CURLOPT_POSTFIELDS,"client_id=0815123-0815123-0815123&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret=Shared Key Secret&grant_type=client_credentials");
curl_setopt($curl_token,CURLOPT_RETURNTRANSFER,1);



$json_response=curl_exec($curl_token) or die("Cannot exec url request");

curl_close($curl_token);


$access_array=json_decode($json_response,true) or die("Cannot decode json");

//print_r($access_array);


if(!isset($access_array["access_token"]))
{
	die("Cannot receive access_token");
}



$curl_token= curl_init();


//https://docs.microsoft.com/ko-kr/graph/api/riskdetection-list?view=graph-rest-beta&tabs=http
curl_setopt($curl_token,CURLOPT_URL, "https://graph.microsoft.com/beta/riskDetections");
curl_setopt($curl_token,CURLOPT_HEADER,0);
curl_setopt($curl_token,CURLOPT_POST,0);
curl_setopt($curl_token,CURLOPT_HTTPHEADER,array("Authorization: Bearer ".$access_array["access_token"]));
curl_setopt($curl_token,CURLOPT_RETURNTRANSFER,1);

$json_response=curl_exec($curl_token) or die("Cannot exec url request");

curl_close($curl_token);

//print_r($json_response);

$risk_array=json_decode($json_response,true) or die("Cannot decode json");

$risk_array=$risk_array["value"];

//print_r($risk_array);


$current_timestamp=time();

/* Look back the last day, therefore  *1 */

$threshold_past=$current_timestamp-(86400*1);

for($i=0; $i<count($risk_array); $i++ )
{
	$riskEvent=$risk_array[$i];
	$activityTimestamp=strtotime($riskEvent["activityDateTime"]);

	if( $activityTimestamp >= $threshold_past )
	{
	
		echo "-----------------------------";

        	echo "\nUser: ".$riskEvent["userPrincipalName"];
       	        echo "\nRisk Type: ".$riskEvent["riskType"];
		echo "\nRisk Level: ".$riskEvent["riskLevel"];
		echo "\nActivity: ".$riskEvent["activity"];
		echo "\nSource: ".$riskEvent["source"];
		echo "\nActivity Date: ".date("c",$activityTimestamp);
		echo "\nLocation: ".$riskEvent["location"]["countryOrRegion"]."/".$riskEvent["location"]["state"];
		echo "\nPlease visit: https://portal.azure.com/#blade/Microsoft_AAD_IAM/SecurityMenuBlade/RiskDetections";
		echo "\n-----------------------------\n";
	}
}


/*

            [15] => Array
                (
                    [id] => foo
                    [requestId] => foo
                    [correlationId] => foo
                    [riskType] => unlikelyTravel
                    [riskEventType] => unlikelyTravel
                    [riskState] => atRisk
                    [riskLevel] => hidden
                    [riskDetail] => hidden
                    [source] => IdentityProtection
                    [detectionTimingType] => offline
                    [activity] => signin
                    [tokenIssuerType] => AzureAD
                    [ipAddress] => ip
                    [activityDateTime] => date
                    [detectedDateTime] => date
                    [lastUpdatedDateTime] => date
                    [userId] => foo
                    [userDisplayName] => name
                    [userPrincipalName] => foo@mail
                    [additionalInfo] => [json_foo]
                    [location] => Array
                        (
                            [city] => Astoria
                            [state] => New York
                            [countryOrRegion] => US
                            [geoCoordinates] => Array
                                (
                                    [latitude] => 0
                                    [longitude] => 0
                                )

                        )

                )



 */


?>

Azure App Registrierung

  • Damit die Graph API zB: mit Shared Secret benutzt werden kann


  • App Registrations d.h. damit eine neue „App“ hinzugefügt werden kann

  • App Bezeichnung RiskDetections um alle risky Users zu ermitteln

  • Permissions ermitteln die gebraucht werden und der App hinzufügen / siehe Microsoft Dokumentation zur jeweiligen API

  • Manche müssen noch granted d.h. erlaubt werden


  • Shared Secret für App erstellen lassen / Nach dem Hinzufügen kann value des neuen Eintrags per copy und paste genommen werden

Powershell Skripte

checkHarddisks.ps1

  • Überprüfe ob es defekte Festplatten gibt
  • Wenn ja sende ein Mail an eine bestimmte E-Mail Adresse über SMTP Relay ohne Authentifizierung oder Krypto
  • As simple as possible um Notifikation durchzuführen
  • Auf dem betroffenen System läuft eine SSD als Systemplatte und 4 Legacy Platten im Storage Pool (Mirror) d.h. Windows sollte alle Festplatten (AHCI/SATA) nativ sehen - kein Hardwareraid
  • Kann als „Aufgabe“ hinzugefügt werden um die Überprüfung täglich zu starten (Programm: powershell.exe Paramter: -ExecutionPolicy bypass C:\PFAD_ZUM_SKRIPT.ps1 )
 $PSEmailServer= "IP_MAILSERVER_RELAY"
 $mailto= "DESTINATION_MAIL"
 $mailfrom= "SENDER_MAIL"


#2022-03-10 cc: Thanks: http://woshub.com/check-hard-drive-health-smart-windows/
$diskFailureInfo=Get-PhysicalDisk | Where-Object {$_.HealthStatus -ne 'Healthy'} | Out-String
$diskFailPredict=Get-WmiObject -namespace root\wmi -class MSStorageDriver_FailurePredictStatus | Where-Object {$_.PredictFailure -eq $true } | Out-String


if( ($diskFailureInfo.Length -gt 0 ) -or ($diskFailPredict.Length -gt 0))
{
$info=$diskFailureInfo+$diskFailPredict
 Send-MailMessage -to $mailto -Subject "$(hostname) Plattenprobleme - ueberpruefen ! " -Body $info -from $mailfrom -port 25 -SmtpServer $PSEmailServer
write-host "Alert $info"
exit 2
}


exit 0

checkLicense.ps1

  • Passwort aus dem BIOS auslesen und falls das Notebook noch nicht aktiviert wurde gleich aktivieren
$foo=Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" | 
where { $_.PartialProductKey }  | select -expand LicenseStatus


if ( -not ( $foo -eq "1" )) 
{

$productKey=(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey

if( -not ($productKey -le 0) )
{

slmgr /ipk $productKey

slmgr /ato

}
else
{
write-host "Cannot find productKey"
}


}
else
{
write-host "Already activated"
}

lastPasswordChange.ps1

  • Finde alle aktiven User deren letzte Passwortänderung länger als $daysLastPasswordChange zurück liegt
$countAll=0
$daysLastPasswordChange=365

$timeThreshold=(Get-Date).Adddays(-($daysLastPasswordChange))

 $userObjects = Get-ADUser -Filter {Enabled -eq $True -and pwdLastSet -lt $timeThreshold} -SearchBase 'LDAP_BASE_USERS' -Properties UserPrincipalName,LastLogonTimeStamp,whenChanged,whenCreated,lastLogon,objectGUID,pwdLastSet,mail

Start-Transcript -path lastPasswordChangeUserTrack.txt 

Foreach ($user in $userObjects)
{

$lastLogon=[datetime]::FromFileTime($user.lastLogon)
$lastPasswordUpdate=[datetime]::FromFileTime($user.pwdLastSet)


   write-host "$($user.UserPrincipalName) - lastPasswordUpdate: $lastPasswordUpdate last Logon: $lastLogon WhenChanged: $($user.whenChanged) WhenCreated: $($user.whenCreated)  "
  
        $countAll+=1
          


}

write-host "All Elements counted: $countAll"
write-host "Days Last Password Update Threshold: $daysLastLogon Days"
Stop-Transcript

lastPasswordChangeUserNotification.ps1

  • Finde alle aktiven User deren letzte Passwortänderung länger als $daysLastPasswordChange zurück liegt und schicke ihnen eine E-Mail , damit sie ihr Passwort ändern
# Mail related
$smtp_server="smtp.office365.com"
$subject = "Passwort zu alt !"

$mail_username="USERNAME_AUTH"
$mail_password="PASSWORD_AUTH"

$securePass = ConvertTo-SecureString $mail_password  -AsPlainText -Force
$mailAuth = New-Object System.Management.Automation.PSCredential ($mail_username, $securePass)
# End mail related

# AD Password Threshold related
$countAll=0
$daysLastPasswordChange=365

$timeThreshold=(Get-Date).Adddays(-($daysLastPasswordChange))
# End mail Threshold related


 $userObjects = Get-ADUser -Filter { Enabled -eq $True -and pwdLastSet -lt $timeThreshold  } -SearchBase 'LDAP_BASE_AD' -Properties UserPrincipalName,LastLogonTimeStamp,whenChanged,whenCreated,lastLogon,objectGUID,pwdLastSet,mail

Start-Transcript -path lastPasswordChangeUserTrack.txt 

#Force TLS1.2 
 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12


Foreach ($user in $userObjects)
{

$lastLogon=[datetime]::FromFileTime($user.lastLogon)
$lastPasswordUpdate=[datetime]::FromFileTime($user.pwdLastSet)


   write-host "$($user.UserPrincipalName) - lastPasswordUpdate: $lastPasswordUpdate last Logon: $lastLogon WhenChanged: $($user.whenChanged) WhenCreated: $($user.whenCreated)  "
   
	if($user.mail)
	{
	$destination= $user.mail
	$mail_content="Bitte aendere deine Zugangsdaten im Schulnetzwerk sobald wie moeglich, deine letzte Passwortaenderung ist zu lange her: $lastPasswordUpdate"
	
	Send-MailMessage -smtpserver $smtp_server -Subject $subject -From $mail_username  -Body $mail_content  -Credential $mailAuth -to $destination -UseSsl

	
        if($?)
        {
        	 #No hammering the smtp server ! / We have no idea what microsofts skynet thinks about sending bulk mail 
	 Start-Sleep -seconds (Get-Random -Minimum 2 -Maximum 10 )

		write-host "SUCCESSFULLLY notified $($user.userPrincipalName) using $($user.mail) "
	}
	else
	{
		write-host "ERROR could not notify $($user.userPrincipalName) using $($user.mail) "
	}
	
	}
	else
	{
	write-host "ERROR could not notify $($user.userPrincipalName) NO mail address listed"
	}
   
        $countAll+=1
          


}

write-host "All Elements counted: $countAll"
write-host "Days Last Password Update Threshold: $daysLastPasswordChange Days"
Stop-Transcript

showWindowsKey.ps1

  • Wenn ers schafft Windows Key auslesen (bei der digitalen Geräteinitiative für die Kids - rechtsklick „Mit powershell ausführen“ / Pic mit Handy machen Copy & Paste bei der Konsole Ausgabe des Keys
Add-Type -AssemblyName System.Windows.Forms 
#wmic path softwarelicensingservice get OA3xOriginalProductKey
$productKey=(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey

if ( $productKey -le 0 )
{
[System.Windows.Forms.MessageBox]::Show("Fehler: Konnte Key nicht auslesen","Windows 10 Produktschluessel",0 ,[System.Windows.Forms.MessageBoxIcon]::Error )


}
else
{
[System.Windows.Forms.MessageBox]::Show("ProductKey: $productKey","Windows 10 Produktschluessel",0,[System.Windows.Forms.MessageBoxIcon]::Information)
}

Write-Host "ProductKey: $productKey"

pause

checkIntuneDevices.ps1 powershell

  • Wenn Geräte durch User enrolled wurden die es nicht mehr gibt können diese im Intune gelöscht werden
  • FIXME mehr checks ID ↔ mail ↔ UPN und zur Sicherheit noch ein „Mindestabstand“ zum Enrollment date
Connect-MSGraph -AdminConsent
Connect-MsolService

$allDevices=0
$deletedDevices=0
$errorDeletedDevices=0
foreach ($currentDevice in Get-IntuneManagedDevice )
{

    $magicCount=(Get-MsolUser -All -searchString $($currentDevice.emailAddress) | Measure-Object).Count

    if($magicCount -eq 0)
    {
        write-host "Current Device Name: $($currentDevice.deviceName)"
        write-host "Current Device Enrollment: $($currentDevice.enrolledDateTime)"
        write-host "Current Device LastSync Time: $($currentDevice.lastSyncDateTime)"
        write-host "Current Device Enrolled by: $($currentDevice.emailAddress)  cannot be found"


        Remove-IntuneManagedDevice -managedDeviceId $($currentDevice.id)

        if($?)
        {
        write-host "SUCCESS: $($currentDevice.deviceName) has been deleted"
         $deletedDevices++

        }
        else
        {
        write-host "FAIL: $($currentDevice.deviceName) couldn't be deleted"
        $errorDeletedDevices++
       
        }
       
        write-host "-----------------------------------------"
    }

   $allDevices++
}
write-host "---------------------"
write-host "Number of devices checked: $allDevices"
write-host "Number of devices successfully deleted from Intune: $deletedDevices"
write-host "Number of devices unsuccessfully deleted from Intune: $errorDeletedDevices"
write-host "---------------------" 

AnalyzeHomeDirectories.ps1 powershell

  • FIXME Beschreibung
$rootDirectories=@("\\FILESERVER_DOMAINS\USER_SHARES_ROOT\*\*","\\FILESERVER_DOMAINS\USER_SHARES_ROOT\_Ausgeschieden\*")
 

$upnSuffix="@DOMÄNE.INTERN"
$dn="DN_LDAP"
$adServer="AD_SERVER"

Start-Transcript -path "AnalyzeHomeDirectories.txt" -append 

ForEach ($rootDirectory in $rootDirectories)
{

	$directories=Get-ChildItem  -Directory $rootDirectory

ForEach ($directory in $directories) 
{

#write-host "Directory: $directory"
#$directory | Get-Member


$upnDirectory=$directory.Name+$upnSuffix




 $adUser=Get-ADUser -server $adServer -searchbase $dn -Properties * -Filter "userPrincipalName -eq '$upnDirectory' -and department -eq 'EIGENSCHAFT' "
 
 if($adUser)
 {
 #$adUser | Get-Member
 #write-host "Ad User found"
 
 $adUserFound=1
 
	 if($adUser.homeDirectory -eq $directory.FullName)
	 {
	 
	 $homeDirectoriesMatch=1
	 }
	 else
	 {
	 $homeDirectoriesMatch=0
	 
	 
	 }
 
 
 
 }
 else
 {
 $adUserFound=0

 }
 

	if($adUserFound -eq 1)
	{
	 if($homeDirectoriesMatch -eq 1)
	 {
	 #write-host "OK - USER SEEMS FINE;Just Name: $($directory.Name);Constructed UPN Name: $upnDirectory;Physical Full Name: $($directory.FullName);AD HomeDirectory: $($adUser.homeDirectory)"
	 }
	 else
	 {
	 $directoryCount = Get-ChildItem $($directory.FullName) -Recurse -Depth 5 -file | Measure-Object
		 
		 if ( -not ($directoryCount.count -eq 0 )) 
		 {

			 if( Test-Path  $($adUser.homeDirectory) )
			 {
				$adDirectoryCount = Get-ChildItem $($adUser.homeDirectory) -Recurse -Depth 5 -file | Measure-Object
			 }
			 
			 write-host "ERROR - USER NOT FINE;Just Name: $($directory.Name);Constructed UPN Name: $upnDirectory;Physical Full Name: $($directory.FullName);AD HomeDirectory: $($adUser.homeDirectory)"
			 #if ( ( -not ( Test-Path  $($adUser.homeDirectory) ) ) -or ($adDirectoryCount.count -eq 0) )
			 
			 robocopy  $($directory.FullName) $($adUser.homeDirectory) /S /E /DCOPY:DA /COPY:DATS /SECFIX /R:2 /W:2 /XO /NP /LOG:C:\Scripts\CopyLog\$($directory.Name).log
				if ($? -eq 0)
				{
				#Remove-Item $($directory.FullName) 
			
				}
				 
			

			
		 }
	 }

	}
	else
	{
	#write-host "FAIL - NO AD USER; Just Name: $($directory.Name);Constructed UPN Name: $upnDirectory;Physical Full Name: $($directory.FullName);"

	}
}
}
#write-host "Constructed UPN name: $upnDirectory"
#write-host "Full Name: $($directory.FullName)"

Stop-Transcript

repairHomeDirectories.ps1 powershell

  • Home Verzeichnisse für User sind nicht vorhanden oder Rechte auf die Home Verzeichnisse passen nicht
  • Von cc geringfügig modifiziert
#####################################################################
# AUTHOR  : Victor Ashiedu 
# DATE    : 01-10-2014
# WEB     : iTechguides.com
# BLOG    : iTechguides.com/blog
# COMMENT : This PowerShell script creates a home folder for all users in Active Directory   
#           (Accessed only by the user) If this script was helpful to you, 
#           please take time to rate it at: http://gallery.technet.microsoft.com/PowerShell-script-to-832e08ed
#####################################################################
############################VERY IMPORTANT:##########################

#before you run this script enure that you read the ReadMe text file
######################################################################

#This script has the following functionalities:#######################

#1 Creates a persoanl (home folder) for all AD users 
#2 Provides option to create users folders as DisplayName or sAMAccountname (Log on name) 
#3 Grants each users "Full Control" to his or her folder
#4 Maps the users folder as drive 'H' (Configured via AD Users property, 
#5 Ensures that users canot access another user's folder

#######################################################################
#######################################################################

#BEGIN SCRIPT

#Define variable for a server to use with query.
#This might be necessary if you operate in a Windows Server 2003 Domain
# and have AD web services installed in a particular DC

$ADServer = 'SERVER_AD' 


#Get Admin accountb credential
#$GetAdminact = Get-Credential 


Import-Module ActiveDirectory

#define search base - the OU where you want to 
# search for users to modify. you can define the 
#domain as your searchbase
#add OU in the format OU=OU 1,Users OU,DC=domain,DC=com

$searchbase = "SEARCHBASE_DN" 

#Search for AD users to modify
#-Credential $GetAdminact 

#$ADUsers = Get-ADUser -server $ADServer -Filter *  -searchbase $searchbase -Properties *
$ADUsers = Get-ADUser -server $ADServer -searchbase $searchbase -Properties * -Filter *


ForEach ($ADUser in $ADUsers) 
{

#Happy Debugging
#$ADUser -properties SamAccountName | Format-List
#$ADUser | Select-Object -Property SamAccountName,homedirectory | Format-List

[string]$pathHomeDirectory = $( $ADUser.homedirectory )
[string]$userPrincipalName= $($ADUser.userPrincipalName )

if ( -not ( Test-Path $pathHomeDirectory ) )
{
write-host("--------");
write-host("Home Directory not found: "+$path);
write-host("AccountName: "+$ADUser.samAccountName);

#Create Missing directory
$homeShare = New-Item -path $pathHomeDirectory -ItemType Directory -force -ea Stop

    Write-Host ("HomeDirectory created at {0}" -f $homeShare)

}
else
{
$homeShare=$pathHomeDirectory

   write-host ("Username: {0}" -f $userPrincipalName)
}

 $acl = Get-Acl $homeShare

    $FileSystemRights = [System.Security.AccessControl.FileSystemRights]“Modify“
    $AccessControlType = [System.Security.AccessControl.AccessControlType]::Allow
    $InheritanceFlags = [System.Security.AccessControl.InheritanceFlags]“ContainerInherit, ObjectInherit“
    $PropagationFlags = [System.Security.AccessControl.PropagationFlags]“None“

    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ($ADUser.SID, $FileSystemRights, $InheritanceFlags, $PropagationFlags , $AccessControlType)
    $acl.AddAccessRule($AccessRule)

    Set-Acl -Path $homeShare -AclObject $acl -ea Stop

   write-host ("ACL's have been modified {0}" -f $homeShare)

}
#END SCRIPT

SimpleAssignLicenses.ps1 powershell

  • Domäne zB: schule.at
  • Kompatibel mit Virtualschool Style des AD's / Auf Grundlagen des Lizenzzuweisungsskripts von Virtualschool nur trivialer
  • Sollte es noch genug A3 Lehrer Lizenzen geben und es sich um einen Lehrer handeln weise A3 Lehrer Lizenz zu
  • Sollte es nicht mehr genug A3 Lehrer Lizenzen geben und es sich um einen Lehrer handeln weise A3 Schüler Lizenz zu
  • Sollte es sich um keinen Lehrer handeln und noch genug A3 Schüler Lizenzen vorhanden sein weise A3 Schüler Lizenz zu
Connect-MsolService

 Start-Transcript -path SimpleAssignLicenes.log 

 $countEntries=0



$StudentA3License=(Get-MsolAccountSku | where {$_.AccountSkuId -like "*M365EDU_A3_STUUSEBNFT"}).AccountSkuId
$TeacherA3License=(Get-MsolAccountSku | where {$_.AccountSkuId -like "*M365EDU_A3_FACULTY"}).AccountSkuId



write-host "Student: $StudentA3License"
write-host "Teacher: $TeacherA3License"


if ( !$StudentA3License -Or ! $TeacherA3License )
{

write-host "License Problems detected cannot assign the Right ones "
exit

}



$TeacherLicenseCount=(Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $TeacherA3License}).ActiveUnits - (Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $TeacherA3License}).ConsumedUnits
$StudentLicenseCount=(Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $StudentA3License}).ActiveUnits - (Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $StudentA3License}).ConsumedUnits

write-host "Available Teacher Licenses: $TeacherLicenseCount"
write-host "Available Student Licenses: $StudentLicenseCount"

#debug licenses available
#Get-MsolAccountSku


if(!$TeacherLicenseCount -And !$StudentLicenseCount)
{
write-host "No Licenses Left !"
exit
}


#-All 
foreach  (  $currentExternalUser in ( Get-MsolUser -All -Synchronized | Where-Object {  $_.UserPrincipalName -NotLike "*#EXT#@*" -and $_.UserPrincipalName -Like "*@schule.at" } ))
{


#debugging is phun
#$currentExternalUser | Get-Member
#$currentExternalUser
#$currentExternalUser.licenses | Get-Member
#write-host "Foo: $foo"
#exit

       if ( $($currentExternalUser.Department) -eq "Lehrer" -and -not ( $($currentExternalUser.Licenses.AccountSkuID) -like '*M365EDU_A3*' ) -and $TeacherLicenseCount -gt 0 )
       {
		if(!$currentExternalUser.isLicensed)
		{
		     Set-MsolUser -UserPrincipalName $currentExternalUser.UserPrincipalName -UsageLocation "AT"
		     Set-MsolUserLicense -UserPrincipalName $currentExternalUser.UserPrincipalName  -AddLicenses $TeacherA3License 

		}
		else
		{
       
  
                     Set-MsolUserLicense -UserPrincipalName $currentExternalUser.UserPrincipalName  -AddLicenses $TeacherA3License -RemoveLicenses  $($currentExternalUser.Licenses.AccountSkuId)
	
		}
         
		if( $? )
		{
		write-host "SUCCESSFULLY replaced TEACHER License on $($currentExternalUser.UserPrincipalName)"

		}
		else
		{

		write-host "ERROR could not replace TEACHER License on $($currentExternalUser.UserPrincipalName)"

		}
		$TeacherLicenseCount=(Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $TeacherA3License}).ActiveUnits - (Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $TeacherA3License}).ConsumedUnits
        }
	else
	{
          	if( -not ( $($currentExternalUser.Licenses.AccountSkuId) -like '*M365EDU_A3_*') -and $StudentLicenseCount -gt 0)
         	{

		   if(!$currentExternalUser.isLicensed)
		   {
			Set-MsolUser -UserPrincipalName $currentExternalUser.UserPrincipalName -UsageLocation "AT"
			

			Set-MsolUserLicense -UserPrincipalName $currentExternalUser.UserPrincipalName  -AddLicenses $StudentA3License 


		   }
 		   else
	  	      	{
 
					
        			 Set-MsolUserLicense -UserPrincipalName $currentExternalUser.UserPrincipalName  -AddLicenses $StudentA3License -RemoveLicenses  $($currentExternalUser.Licenses.AccountSkuId)
			}
        
		if( $? )
		{
		write-host "SUCCESSFULLY replaced PUPILS License on $($currentExternalUser.UserPrincipalName)"

		}
		else
		{

		write-host "ERROR could not replace PUPILS License on $($currentExternalUser.UserPrincipalName)"

		}
		$StudentLicenseCount=(Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $StudentA3License}).ActiveUnits - (Get-MsolAccountSku | Where-Object {$_.AccountSkuId -eq $StudentA3License}).ConsumedUnits


		}
		else
		{
		write-host "NOT replacing License on $($currentExternalUser.UserPrincipalName)"
		}
	}
	$countEntries++;



}

write-host "Entries: $countEntries"
write-host "Available Teacher Licenses: $TeacherLicenseCount"
write-host "Available Student Licenses: $StudentLicenseCount"
Stop-Transcript

repair_ext_outlook.ps1 powershell

  • Durch eine Verkettung unglücklicher Umstände kam es zu folgender Situation
    • Addressobjekte die Teil von Gruppenverteilern sind (durch die #EXT#@ Einträge in der Cloud ersichtlich) bekamen Lizenzen zugewiesen
    • Durch die Lizenzzuweisung wurde das proxy smtp:mailadresse Attribut der Einträge entfernt - beim Versand an die Gruppenverteiler kann der MS Mechanismus zum Auflösen die Mail Adressen nicht mehr „finden“
    • Dieser Fehler wird erst ersichtlich sobald die Gruppenverteiler im Outlook expandiert werden und eine Übermittlungsbestätigung angefordert wird ( 500er Fehler der MS Mail Server .. proxyAddresses primary Mail attribute missing )
    • Dieses Skript entfernt die Lizenz und weist den Einträgen wieder die Mailadresse zu

$365Logon = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $365Logon -Authentication Basic -AllowRedirection

Connect-MsolService

Import-PSSession $Session -AllowClobber

 Start-Transcript -path repair-ext-outlook-logging.txt -NoClobber

 $countEntries=0
 
foreach  (  $currentExternalUser in ( Get-MailUser -ResultSize unlimited | Where-Object {  $_.UserPrincipalName -like "*#EXT#@*"  -and $_.RecipientTypeDetails -eq "GuestMailUser"} ))
{


$currentExternalUserLicense=Get-MsolUser -UserPrincipalName $currentExternalUser.UserPrincipalName

if ( $currentExternalUser.UserPrincipalName )
{
	if( $currentExternalUserLicense.isLicensed )
	{
	Set-MsolUserLicense -UserPrincipalName $currentExternalUser.UserPrincipalName -RemoveLicenses "SCHULE:STANDARDWOFFPACK_IW_STUDENT"

		if( $? )
		{
		write-host "Successfully removed License on $($currentExternalUser.UserPrincipalName)"

		}
		else
		{

		write-host "ERROR could not remove License on $($currentExternalUser.UserPrincipalName)"

		}

	}

	Set-Mailuser -Identity $currentExternalUser.UserPrincipalName -EmailAddresses $currentExternalUser.ExternalEmailAddress

	if( $? )
	{

	write-host "Successfully set Email: $($currentExternalUser.ExternalEmailAddress) on $($currentExternalUser.UserPrincipalName)"

	}
	else
	{
	write-host "ERROR could not set Email Address on: $($currentExternalUser.UserPrincipalName)"
	}

	$countEntries++;


}

}

write-host "Entries: $countEntries"

Stop-Transcript

Remove-PSSession $Session

fix-wds-workstations.ps1 powershell

  • WDS und DHCP laufen auf selben Server
  • Um die Zuordnung von MAC Adresse der Maschine ↔ zu Deployment AD Name zu fixieren
param( [Parameter(Mandatory=$true)]
[string]$searchCriteria
)

$domainSuffix=".local-domain.local"

foreach ($macAddress in  Get-DhcpServerv4Scope | Get-DhcpServerv4Lease -AllLeases  | Where-Object  {$_.hostname -like $searchCriteria } ) 
{

if ( $macAddress.hostname -like "*$domainSuffix" )
{
   $hostname=$macAddress.hostname.split(".")[0]
   
echo "Setting WDS parameter : $($macAddress.clientid);$hostname"

Set-WdsClient -DeviceName $hostname -DeviceId $macAddress.clientid

}
else
{
   echo "Not a domain joined computer: $($macAddress.clientId);$($macAddress.hostname))"
}

}

cleanGroupsOffice365.ps1 powershell

  • Getestet auf Windows 10 LTSC 2019 FIXME
  • Achtung zum löschen aller Gruppen die nicht durch AD Gruppenzugehörigkeit erstellt wurden (bei einer Virtualschool Installation
  • Mit dem letzten auskommentierten Eintrag ist es auch möglich alle Objekte aus dem Papierkorb zu löschen
  
$adminUPN="admin@domain"

Connect-MsolService
Connect-AzureAD


$countGroups=0

echo "OwnerName;;OwnerDepartment;;DisplayName;;CommonName;;E-Mail Address;;Description" > "Delete-Groups.csv"

foreach  (  $currentGroup in ( Get-MsolGroup -All | Where-Object { -not $_.GroupType -eq 'MailEnabledSecurity'  } ))
{

$objectId=$currentGroup.objectId

$objectOwner=Get-AzureADGroupOwner -ObjectId $objectId

write-host "Remove: OwnerName: $($objectOwner.UserPrincipalName) ,OwnerDepartment: $($objectOwner.Department),  DisplayName: $($currentGroup.DisplayName) , CommonName:  $($currentGroup.CommonName) , E-Mail Address:  $($currentGroup.EmailAddress) , Description: $($currentGroup.Description)"

echo "$($objectOwner.UserPrincipalName);;$($objectOwner.Department);;$($currentGroup.DisplayName);;$($currentGroup.CommonName);;$($currentGroup.EmailAddress);;$($currentGroup.Description)" >> "Delete-Groups.csv"
Remove-MsolGroup -ObjectId $currentGroup.objectId -Force
$countGroups++;


}
 
 write-host "Count all matching Groups: $countGroups"

#Get-AzureADMSDeletedGroup | Remove-AzureADMSDeletedDirectoryObject

removeRemoved-office365.ps1 powershell

  • Gelöschte Cloud Benutzer endgültig löschen (vor Ablauf der 30 Tages Frist)
  • Achtung Getestet mit Windows 10 LTSC 2019
  • Windows 2012r2 erkennt den -RemoveFromRecycleBin - nach mehreren Stunden des erfolglosen Versuchs das Modul zu aktualisieren wurde es auf Windows 10 durchgeführt
 
$adminUPN="admin@DOMAIN"

$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password"


 Connect-MsolService -Credential $userCredential
 
 Start-Transcript -path connect-office365-logging.txt -NoClobber
 
foreach ( $currentUser in   Get-MsolUser -ReturnDeletedUsers -All  )
{
$currentPrincipal = $currentUser.UserPrincipalName

write-host "Soll User mit der UPN: $currentPrincipal gelöscht werden?"

Remove-MsolUser -UserPrincipalName $currentUser.UserPrincipalName -RemoveFromRecycleBin



}

Stop-Transcript

manCreatePupils.ps1 powershell

  • Quick and Dirty anlegen von AD User Accounts + Sync in die Cloud (proxyAddresses)
  • PATH_FILE im Format vorname.nachname@domain;Passwort
max.mustermann@domain;PASSWORD_ACCOUNT
  • manCreatePupils.ps1
$delim=";"

$lines=Get-Content -Path PATH_FILE

$ouPath="TARGET_OU_DISTINGUISHED_PATH"
 

 
Foreach ($singleMail in $lines)
{

    
$userPassword=$singleMail.split($delim)[1]
$singleMail=$singleMail.split($delim)[0]

if([string]::IsNullOrEmpty($UserPassword))
{
$userPassword="4598j56778"
}

 $securePass = ConvertTo-SecureString $userPassword  -AsPlainText -Force
 
 
$fullName=$singleMail.split("@")[0]

$forename=$fullName.split(".")[0]
$lastname=$fullName.split(".")[1]

write-host "Bearbeite: $singleMail , Forename: $forename , Lastname: $lastname , Password: $userPassword"


if ( "$forename.$lastname".length -lt 20 )
{
New-ADUser -Name "$forename.$lastname" -SamAccountName "$forename.$lastname" -UserPrincipalName $singleMail -Path $ouPath -Enabled $true -AccountPassword $securePass   -OtherAttributes @{'proxyAddresses'="SMTP:$singleMail"} -EmailAddress $singleMail

}
else
{
New-ADUser -Name "$forename.$lastname" -SamAccountName ("$forename.$lastname").substring(0,20) -UserPrincipalName $singleMail -Path $ouPath -Enabled $true -AccountPassword $securePass   -OtherAttributes @{'proxyAddresses'="SMTP:$singleMail"} -EmailAddress $singleMail

}


if( -not ( $? ) )
{

echo "FEHLER - E-mail: $singleMail Vorname: $forename Nachname: $lastname Password: $userPassword" | Out-File -FilePath PATH_DEBUG_FILE -Append
echo "FEHLER - E-mail: $singleMail Vorname: $forename Nachname: $lastname Password: $userPassword"
}
else
{
	echo "OK - E-mail: $singleMail Vorname: $forename Nachname: $lastname Password: $userPassword" |  Out-File -FilePath PATH_DEBUG_FILE -Append
	echo "OK - E-mail: $singleMail Vorname: $forename Nachname: $lastname Password: $userPassword"
}


}

countUnusedUsers powershell

  • countUnusedUsers.ps1
$countAll=0
$daysLastLogon=180

$timeThreshold=(Get-Date).Adddays(-($daysLastLogon))

 $userObjects = Get-ADUser -Filter {LastLogonTimeStamp -lt $timeThreshold} -SearchBase 'LDAP_BASE' -Properties UserPrincipalName,LastLogonTimeStamp,whenChanged,whenCreated,lastLogon,objectGUID

Start-Transcript -path unusedUserTrack.txt 

Foreach ($user in $userObjects)
{

$lastLogon=[datetime]::FromFileTime($user.lastLogon) 


   write-host "$($user.UserPrincipalName) -  last Logon: $lastLogon WhenChanged: $($user.whenChanged) WhenCreated: $($user.whenCreated)  "

   #Disable-ADAccount -Identity $($user.objectGUID)

	if($? )
	{
	write-host "SUCCESSFULLLY disabled $($user.userPrincipalName) "
	}
	else
	{
	write-host "ERROR could not disable $($user.userPrincipalName) "
	}



        $countAll+=1
     


}

write-host "All Elements counted: $countAll"
write-host "Days Logon Threshold: $daysLastLogon Days"
Stop-Transcript

countAndCleanUnusedComputers powershell

$countAll=0
$daysLastLogon=180

$timeThreshold=(Get-Date).Adddays(-($daysLastLogon))

 $ComputerObjects = Get-ADComputer -Filter {LastLogonTimeStamp -lt $timeThreshold} -SearchBase 'LDAP_BASE' -Properties Name,LastLogonTimeStamp,whenChanged,whenCreated,lastLogon

Start-Transcript -path unusedComputerTrack.txt -NoClobber

Foreach ($computer in $ComputerObjects)
{

$lastLogon=[datetime]::FromFileTime($computer.lastLogon) 


   write-host "$($computer.Name) -  last Logon: $lastLogon WhenChanged: $($computer.whenChanged) WhenCreated: $($computer.whenCreated)  "

Remove-ADObject -Identity $computer -Confirm -Recursive
        $countAll+=1
          


}

write-host "All Elements counted: $countAll"
write-host "Days Logon Threshold: $daysLastLogon Days"
Stop-Transcript

countComputers powershell

  • countComputers.ps1
$OUs = (Get-ADOrganizationalUnit -Filter * -SearchBase 'LDAP_BASE' -SearchScope Subtree) 

$countAll=0

$daysLastLogon=180

$timeThreshold=(Get-Date).Adddays(-($daysLastLogon))

Foreach ($item in $OUs){
    $ComputerObjects = Get-ADComputer -Filter {LastLogonTimeStamp -gt $timeThreshold} -SearchBase $item.DistinguishedName -SearchScope OneLevel

    If($ComputerObjects){

$magicCount=($ComputerObjects | Measure-Object).Count

      write-host "$($item.Name) - $magicCount"

        $countAll+=$magicCount
             
        }


}

write-host "All Elements counted: $countAll"
write-host "Days Logon Threshold: $daysLastLogon Days"

cloudUserDetails powershell

  • cloudUserDetails.ps1
  • .\cloudUserdetails.ps1 -searchUser christian
  • Um herauszufinden ob die Ankerung der lokalen AD User in die Microsoft Cloud korrekt durchgeführt wird - bei Synchronisierungsproblemen sehr hilfreich
param(
[string]$searchUser="mustermann"
)
 
$adminUPN="admin@DOMAIN"

$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password"


 Connect-MsolService -Credential $userCredential


$incorrectID=0
$correctID=0
$incorrectAD=0

foreach ( $currentUser in   Get-MsolUser  -All  -Search $searchUser)
{
$principalNameCloud=$currentUser.UserPrincipalName 
$immutableIdCloud=$currentUser.ImmutableId

$guidCloud=[GUID][system.convert]::FromBase64String($immutableIdCloud)

$username=$principalNameCloud

$currentADUser=Get-ADUser -Filter "(UserPrincipalName -eq '$username')"  -SearchBase "LDAP_SEARCH_BASE"

$currentADUserCount=(Get-ADUser -Filter "(UserPrincipalName -eq '$username')"  -SearchBase "LDAP_SEARCH_BASE").count

write-host "---------------------------------------------------------"

write-host "Current Cloud User: $principalNameCloud"
write-host "Current Cloud GUID: $guidCloud"

	if(-not ($currentADUserCount -gt 1) -and -not ($currentADUserCount -eq 0) )
	{
	$immutableIdAdUser= [system.convert]::ToBase64String(([GUID]$currentADUser.objectGUID).ToByteArray())
 
		if($immutableIdAdUser -eq $immutableIdCloud)
		{
		   write-host "UPN: $principalNameCloud has correct ImmutableID"
			$correctID++;
		}
		else
		{
		  write-host "UPN: $principalNameCloud has incorrect ImmutableID"
		  $incorrectID++;
		}
		

	}
	else
	{
	$guidUser=Get-ADUser -Filter "(objectGuid -eq '$guidCloud')"  -SearchBase "LDAP_SEARCH_BASE"
	
	
	write-host "UPN: $principalNameCloud has not been found in AD!!"
	write-host "BUT Matching Guid: $guidUser"
	
	$incorrectAD++;
	}
	write-host "------------------------------------------------"
 }

clean-groups powershell

  • ACHTUNG Um Gruppen zu löschen die keine Mitglieder haben
  • clean_groups.ps1
param(
[string]$searchFilter="*"
)

$ldapBase="DISTINGUISHED_NAME_LDAP_BASE_OU"

foreach ($adGroup in Get-ADGroup -SearchBase $ldapBase -Filter $searchFilter)  
{

$groupCount= (Get-AdgroupMember -Identity $adGroup -recursive).count

if( $groupCount -eq 0 )
{
  remove-adgroup -Confirm $adGroup
}


}

restart-workstations powershell

  • restart-workstations.ps1
  • zB: .\restart-workstations.ps1 -searchCriteria *EDV*
param(
[string]$searchCriteria="*"
)

$ldapBase="OU=Workstations,OU=Ressourcen,DC=schule,DC=intern" 

$i=0

foreach ($domainComputer in Get-ADComputer -LDAPFilter "(name=$searchCriteria)" -SearchBase $ldapBase )
{

  echo "Restarting Computer: $($domainComputer.dnsHostname)"

  Restart-Computer -Force -ComputerName $($domainComputer.dnsHostname)  2> $null

  $i++

}

echo "Computer Count: $i"

shutdown-workstations powershell

  • shutdown-workstations.ps1
  • zB: .\shutdown-workstations.ps1 -SearchCriteria *EDV*
param(
[string]$searchCriteria="*"
)

$ldapBase="OU=Workstations,OU=Ressourcen,DC=schule,DC=intern" 

$i=0

foreach ($domainComputer in Get-ADComputer -LDAPFilter "(name=$searchCriteria)" -SearchBase $ldapBase )
{

  echo "Stopping Computer: $($domainComputer.dnsHostname)"

  Stop-Computer -Force -ComputerName $($domainComputer.dnsHostname)  2> $null

  $i++

}

echo "Computer Count: $i"

wake-on-lan dhcp leases powershell

  • wake-on-lan.ps1
  • zB: .\wake-on-lan.ps1 -SearchCriteria *EDV101*
param(
[string]$searchCriteria="*"
)


#wake on lan https://gallery.technet.microsoft.com/scriptcenter/Send-WOL-packet-using-0638be7b
#Begin wake on lan code
function Send-WOL
{
<# 
  .SYNOPSIS  
    Send a WOL packet to a broadcast address
  .PARAMETER mac
   The MAC address of the device that need to wake up
  .PARAMETER ip
   The IP address where the WOL packet will be sent to
  .EXAMPLE 
   Send-WOL -mac 00:11:32:21:2D:11 -ip 192.168.8.255 
#>

[CmdletBinding()]
param(
[Parameter(Mandatory=$True,Position=1)]
[string]$mac,
[string]$ip="255.255.255.255", 
[int]$port=9
)
$broadcast = [Net.IPAddress]::Parse($ip)
 
$mac=(($mac.replace(":","")).replace("-","")).replace(".","")
$target=0,2,4,6,8,10 | % {[convert]::ToByte($mac.substring($_,2),16)}
$packet = (,[byte]255 * 6) + ($target * 16)
 
$UDPclient = new-Object System.Net.Sockets.UdpClient
$UDPclient.Connect($broadcast,$port)
[void]$UDPclient.Send($packet, 102) 

}

# End wake on lan Code

foreach ($macAddress in  Get-DhcpServerv4Scope | Get-DhcpServerv4Lease  | Where-Object  {$_.hostname -like $searchCriteria } ) 
{
   echo "Sending wol to : $($macAddress.clientid);$($macAddress.hostname)"
   Send-WOL -mac $($macAddress.clientId)
}

rdp server zertifikat austauschen

  • Für die Domäne , in diesem Beispiel schule.intern wird ein Wildcard Zertifikat von einer für das System gültigen CA ausgestellt die auf allen Servern ausgerollt wurde, auf die per RDP zugegriffen wird *.schule.intern
  • Im Linux wird das CA Zertifikat zum System hinzugefügt (dpkg-reconfigure ca-certificates - siehe Linux)
  • rdesktop (1.9.0) und xfreerdp (2.0.0-dev5 (2693389a+debian)) überprüfen nun das SSL Zertifikat und melden KEINE Fehlermeldung wenn das Zertifikat korrekt unterschrieben wurde und der Hostname als FQDN für den Zugriff richtig gesetzt

wmic /namespace:\\root\cimv2\TerminalServices PATH Win32_TSGeneralSetting Set SSLCertificateSHA1Hash="5d969239c9de854cc3af8c3b16deb1ab85b4fcc2"

adconnect

adconnect - Seamless SSO aktivieren

  • Achtung zusätzliches Firewalling:
#2022-09-06 cc: SSO activate / adconnect
\.registration.msappproxy.net
\.msappproxy.net

office 365 powershell

$minLength = 5 ## characters
$maxLength = 10 ## characters
$length = Get-Random -Minimum $minLength -Maximum $maxLength
$nonAlphaChars = 5
$password = [System.Web.Security.Membership]::GeneratePassword($length, $nonAlphaChars)
  • Office365 Set Password
 Set-MsolUserPassword -UserPrincipalName "davidchew@consoso.com" -NewPassword "pa$$word"
  • Office365 gelöschte User restoren als „alter UPN-restore“
 
$adminUPN="admin@domain"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password"


 Connect-MsolService -Credential $userCredential
 
foreach ( $currentUser in   Get-MsolUser -ReturnDeletedUsers -All )
{
$principalNameOld=$currentUser.UserPrincipalName 

$principalNameNew=$principalNameOld.split("@")[0]+"-restore@domain"

write-Host "Original Name: $principalNameOld , New Name: $principalNameNew"

Restore-MSolUser -UserPrincipalName $principalNameOld -NewUserPrincipalName $principcalNameNew -AutoReconcileProxyConflicts

}
  
  • Gelöschte Sharepoint Seiten anzeigen
Import-Module -Name Microsoft.Online.SharePoint.PowerShell

$adminUPN="admin@domain"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."

Connect-SPOService -Url https://ORGANISATION-admin.sharepoint.com -Credential $userCredential

Get-SPODeletedSite -IncludePersonalSite

  • Bulks Restore von gelöschten Usern - mit Mail Notification ihres Passworts für den Restore Account
 
 #office 365 administration specific
$adminUPN="admin@pdomain"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password"

Connect-MsolService -Credential $userCredential
 
 if(!$?)
 {
 write-Host "Could not Connect to Office 365 Service"
 
 exit 2
 
 }
 
#Mailserver and useraccount that will be abused for notification of the users e.g. Microsoft smtp
 $smtpServer="smtp.office365.com"
 $mailUsername="E-MAIL-ADDRESS"
 $mailPassword="E-MAIL-PASSWORD"
 
 $securePass = ConvertTo-SecureString $mailPassword  -AsPlainText -Force
$mailAuth = New-Object System.Management.Automation.PSCredential ($mailUsername, $securePass) 
 
 $successRestore="false"
 $successPassword="false"
 $successMail="false"
 $simplePassword="false"
 
foreach ( $currentUser in   Get-MsolUser -ReturnDeletedUsers -All -Search "SEARCH_PATTERN_NAME_TESTING" )
{

#Get the old UserPrincipal Name that conains an e-mail 
$principalNameOld=$currentUser.UserPrincipalName 

#Construct the new UserPrincipal Name 
$principalNameNew=$principalNameOld.split("@")[0]+"-restore@domain"

$mailSubject="Alter Account: "+$principalNameNew

Restore-MSolUser -UserPrincipalName $principalNameOld -NewUserPrincipalName $principalNameNew -AutoReconcileProxyConflicts

if($?)
{
	$successRestore="true"

	#OK User could be restore with new Principal Name - Let's create a SIMPLE password for him
	$simplePassword = "AcD!"+(Get-Random -Minimum 1000000 -Maximum 9999999)


	 Set-MsolUserPassword -UserPrincipalName $principalNameNew -NewPassword $simplePassword 
  
	if($?)
	{
		$successPassword="true"

		$mailBody="Hallo, `r`n deine alten Daten wie Mail/OneDrive erreichst du folgendermaßen:`r`n Login https://login.microsoftonline.com `r`n Benutzername: "+$principalNameNew+"`r`n Passwort: "+$simplePassword+"`r`n LG Das IT Team"

		Send-MailMessage -smtpserver $smtpServer -Subject $mailSubject -From $mailUsername  -Body $mailBody  -Credential $mailAuth -to $principalNameOld -UseSsl

		if($?)
		{

			$successMail="true"

		}
		else
		{
			$successMail="false"
		}
		 
	 }
	 else
	 {
			$successPassword="false"
	 }
	 #Lets pause the process we don't know if we can send that many mails without being marked as Spam or something else
	 Start-Sleep -seconds (Get-Random -Minimum 2 -Maximum 10 )

}
else
{
$successRestore="false"
}


write-Output "$principalNameOld;$principalNameNew;$simplePassword;$successRestore;$successPassword;$successMail" | Tee-Object -Append -FilePath "C:\Scripts\restore.txt" 

}
  
  
  

poor mans windows advanced threat protection - intune

  • Getestet mit Windows 10 Pro (1909) / Windows 10 LTSC 2019
  • Intune vollverwaltet und teilverwaltete Geräte
  • Über Intune wird über die „Skripts“ Funktionalität ein Mechanismus deployed der analog zur Variante mit E-Mail / Kerberos Notifikationen eine Notifikation über einen Web Endpunkt triggered sobald ein Virus durch den Windows Defender gefunden wird

Server - Intune

  • Bei Geräte - Skripts - Hier werden alle Skripte angezeigt:

  • Das bereits hochgeladene Skript wurde ATP-Deploy benannt - nach einiger Zeit (nach 2 Tagen wieder überprüft) erscheint eine Statistik mit „Gerätestatus“ , „Benutzerstatus“

  • Das bereits hochgeladene Powershell Skript könnte nun wieder hochgeladen werden / Achtung in diesem Beispiel läuft es mit SYSTEM aka. root Berechtigungen / Das Powershell Skript wird nur für Mitglieder der Gruppe ATP-Geräte angewandt

  • In diesem Punkt könnte es nochmals hochgeladen oder geändert werden / Achtung nach dem Upload ist es nicht mehr möglich (ich habs noch nicht debugged) herauszufinden was eigentlich ausgeführt wird :) / Beim Hinzufügen handelt es sich um das gleiche User Interface / In meinem Fall möchte ich das Skript als SYSTEM ausführen auf 64 Bit Maschinen / Bei Überprüfen lässt sich noch die Gruppe angeben für die das Skript Gültigkeit hat - ATP-Geräte / Bei erneutem Hochladen eines geändert Skripts wird das Powershell Skript nochmals ausgeführt / Sonst wird es laut MS Doku nur einmal ausgeführt / Skriptbeispiel: atp-deploy-system.ps1.zip

  • Wie kommt es zur Zuweisung zur Gruppe der ATP-Geräte / über Umwege - die Gerätekategorie

  • Die Sicherheitsgruppe ATP-Geräte enthält Devices denen die Gerätekategorie ATP-Prototyping zugewiesen wurde

Endgerät - Workstations

  • Debugging auf dem Endgerät
  • Die Intune Management Extension muss auf dem Gerät automatisch installiert werden damit die Powershell Skripte ausgeführt werden
  • Überprüfung ob das Gerät im Intune registriert wurde

  • Informationen zur Registrierung / Microsoft Intune Management Extension muss nach einiger Zeit (Testraum Check 2 Tage) erscheinen

  • Synchronisierung kann auch manuell nochmals angeworfen werden / Laut MS Docs wird sie auch bei Neustart und erneutem Login angestoßen / Es war nicht ersichtlich wodurch die Microsoft Intune Management Extension getriggered wird

  • Sobald installiert befinden sich einige Logfiles in diesem Verzeichnis C:\ProgramData\Microsoft\IntuneManagementExtension\

Microsoft 365 Defender - ATP

  • Offenbar bekommen Bundesschulen aktuell 100 Lizenzen für die ATP/MS 365 Defender
  • Geräte muss „geboarded“ werden d.h. Logik muss auf dem jeweiligen Client installiert werden
  • Keine MSI Datei sondern good old fashioned magic *.cmd / Batch File für Deployment von Microsoft
  • Anforderungen: Ich möchte ein Notification Mail bekommen wenn zB: Viren gefunden werden mit Gerätename und Virenfund/Malware Fund Info

poor mans windows advanced threat protection - lokal

  • Getestet auf Windows LTSB 2016 64Bit / LTSC 2019
  • Es soll bei Virus/Malware Fund durch Windows Defender eine Notifikation an eine zentrale Stelle erfolgen
  • Regelmäßiges Scannen auf einem Server könnte zB: folgendermaßen gelöst werden , im folgenden Beispiel wird das Laufwerk G:\ gescannt → speichern als .ps1 und in Task Planer aufnehmen zB: wöchentlich
  • ScanStorage.ps1
Update-MpSignature
Start-MpScan -ScanType CustomScan -ScanPath G:\

poor mans harddisk notification check - lokal

  • Aus aktuellem Anlass - da 200GB SSD Platten / NVMEs im Schulbereich zu klein sind / Wenn lokale Profile verwendet werden und zahlreiche User sich auf dem Gerät einloggen
  • Enthält ein Powershell Skript (C:\Scripts\*.ps1) , das beim Start (Aufgabe *.xml) ausgeführt wird / Durch das Batch file (*.bat) kann es als Computerrichtlinie deployed werden
  • Wenn die Geräte unter 16GB frei haben oder ein Festplattenproblem / Dateisystem Problem festgestellt wird , wird ein POST Request an das Support System getriggered, das eine Mail an den zuständigen Betreuer versendet
  • Beispiel Mail:

poor mans updates available check - lokal

  • Beispiel Mail:

APC-USB-USV remote server shutdown

  • Gesetzt folgendem Fall - eine APC USV hängt per USB an einem Server und es wird ein Zweiter hinzugefügt und an der USV angehängt / Für diese USV Reihe existiert jedoch keine Management Interface Karte , daher weiß der „remote“ Server nicht wann die USV aktiv wird bei Stromausfall
  • Auf dem „Host“ Server der per USB mit der USV verbunden ist werden in der Aufgabenplanung Tasks (batch Files) gestartet um den zweiten Server bei Bedarf herunterzufahren
  • Getestet auf Host Server Windows 2012r2 Standard und Remote Server Windows 2016 Standard
  • Konfiguration „Host“ Server der mit USV verbunden ist
  • Achtung USV wird als „Akku“ angezeigt - das Skript liest die aktuelle Akku Ladung raus, fällt das Ladeniveau unter einen bestimmten threshold zB: 30% wird ein event getriggered , das beim zweiten Job dazu führt dass das Shutdown Skript ausgeführt wird
  • XML Konfigurationen für die Tasks shutdown_server_on_low_battery.xml.gz ,check_battery.xml.gz
  • Batch Dateien für die Skripte: scripts.zip , Check Battery stammt von https://superuser.com/questions/1162575/windows-event-id-for-battery-level-change - „the fixed one“
  • In scripts.zip befindet sich auch eine powershell Variante zum Herunterfahren - hier müsste bei der zu startenden Applikation powershell.exe gewählt werden + Parametern könnte Ausführung zB: folgendermaßen sein powershell.exe -ExecutionPolicy Bypass c:\scripts_shutdown\shutdown-server.ps1
  • Konfiguration „Remote Server“ der durch Windows Boardmittel shutdown vom „Host“ Server heruntergefahren wird
  • Lokalen Standard User anlegen:

  • Lokalen Standard User Herunterfahren von Remote erlauben
  • gpedit.msc

  • Netzwerkkonfiguration Datei und Druckerfreigabe damit psshutdown connecten kann

Software RAID1 mit Windows Boardmitteln

  • Getestet auf Windows 2012r2 mit Hp Microserver gen8 und 2 SSD Platten / MBR Boot
  • Im Wesentlichen über die GUI:
    • Computerverwaltung
    • Datenträger auswählen → konvertieren in Dynamischen
    • zB: Wenn Datenträger 0 gespiegelt werden soll auf Datenträger 1
    • Datenträger 1 vollständig löschen alle Volumes falls vorhanden
    • Datenträger 0 rechtsklick auf Partition Spiegelung hinzufügen → Datenträger1 auswählen
  • Sollte „Die Synchronisation wird wiederholt“ - ohne Prozentanzeige stehen - klick in betroffene Spiegelung und einmal F5 drücken und er aktualisiert die Anzeige mit Prozentangabe

Boot Treiber auf AHCI stellen

    Run Registry Editor.

    To do it, press Win + R and type in the command regedit.

    Go to the section HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ iaStorV
    Regedit. Go to the section HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ iaStorV

    Double-click on Start element and set its value to 0 (zero).
    Regedit. Double-click on Start element and set its value to 0 (zero).

    In the next section, HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ iaStorAV\ StartOverride set the zero value for the element 0.
    Regedit. HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ iaStorAV\ StartOverride set the zero value for the element 0

    In the section HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ storahci set the value to 0 (zero) for Start element.
    Regedit. HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ storahci set the value to 0 (zero) for Start element.

    In the subsection, HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Services\ storahci\ StartOverride set the zero value for the element 0.
    In our case, there is nothing to see, but you will see it, if AHCI has not been enabled yet.

    Close Registry Editor.

Fileserver Deduplizierung

  • Wenn ausreichend I/O und CPU Power vorhanden kann die Deduplizierung genutzt werden um Speicher zu gewinnen / Achtung Wenn das Dateisystem fehlerhaft wird oder einzelne Dateien beschädigt werden in Folge alle betroffenen beschädigt da die Deduplizierung die redundanten Daten nur einmal speichert - daher auch der Speichergewinn - you have been warned :)
  • In der Praxis konnte ich auf einem Fileserver mit >1.5 Mio Dateien von 800GB auf 2TB (!) Speicher gewinnen
  • Getestet auf einem Windows 2016 (hyper V Hostsystem mit 2CPUs u. RAID10 4TB SSDs / hyper v Gast / Generation 2 / 2 CPUs / dynamischen RAM bis zu 8GB)

Fileserver Migration von Shares

Backup and Restore of Share Permissions

To backup share permissions, export the Shares registry key.

    Open Regedit to the following location:

    HKLMSYSTEMCurrentControlSetServicesLanmanServerShares
    Right-click the Shares registry key and select Export. Give it a file name such as shareperms.reg.

When you want to restore the permissions, double-click shareperms.reg to import it back into the registry.

Use the Reg tool to backup the registry key from the command line:

    reg export HKLMSYSTEMCurrentControlSetServicesLanmanServerShares shareperms.reg

If you need to restore it at some point, just run:

    reg import shareperms.reg

Backup and Restore of NTFS Permissions

Use this command to backup NTFS permissions:

    icacls d:data /save ntfsperms.txt /t /c

The /T switch allows it to get subfolder permissions too. The /C switch allows it to continue even if errors are encountered (although errors will still be displayed).

Use this command to restore them:

    icacls d: /restore ntfsperms.txt

Note that in the command to save the permissions, I specified the target folder D:Data, but when I restored them, I specified just D: as the target. Icacls is a little funky like that, and here’s why.

If you open the text file with the exported permissions (ntfsperms.txt in the above example), you’ll see that Icacls uses relative paths (in bold below). Underneath the relative paths are the permissions for the folders in Security Descriptor Definition Language (SDDL) format.

data
D:AI(A;ID;FA;;;BA)(A;OICIIOID;GA;;;BA)(A;ID;FA;;;SY)(A;OICIIOID;GA;;;SY)(A;OICIID;0x1200a9;;;BU)(A;ID;0x1301bf;;;AU)(A;OICIIOID;SDGXGWGR;;;AU)
datafolder1
D:AI(A;ID;FA;;;BA)(A;OICIIOID;GA;;;BA)(A;ID;FA;;;SY)(A;OICIIOID;GA;;;SY)(A;OICIID;0x1200a9;;;BU)(A;ID;0x1301bf;;;AU)(A;OICIIOID;SDGXGWGR;;;AU)
datafolder2
D:AI(A;ID;FA;;;BA)(A;OICIIOID;GA;;;BA)(A;ID;FA;;;SY)(A;OICIIOID;GA;;;SY)(A;OICIID;0x1200a9;;;BU)(A;ID;0x1301bf;;;AU)(A;OICIIOID;SDGXGWGR;;;AU)

Had I specified D:Data in the command to restore the permissions, it would have failed looking for a D:DataData folder:

D:>icacls d:data /restore perms.txt
d:datadata: The system cannot find the file specified.
Successfully processed 0 files; Failed processing 1 files

You might think specifying D: as the target in the restore command may somehow mess up the permissions on other folders at that level, but as you can see from the ntfsperms.txt output file, it only has information about the Data folder and subfolders, so that is all it will change.

– Craig Landis
  • Empfehlung nur NTFS Permissions verwenden dann reicht robocopy zum Kopieren aus und es müssen nur die entsprechenden Shares erstellt (fsmgmt.msc) werden mit Share Permission FULL für „Jeder“
  • d.h. robocopy \\QUELLE\Share ZIELLAUFWERK:\Share /TEE /S /E /DCOPY:DA /COPY:DATS /SECFIX /PURGE /MIR /R:5 /W:30 /log:C:\TMP\Log-Kopieren.txt
  Gestartet: Donnerstag, 17. Mai 2018 11:54:04
   Quelle : \\QUELLE\Share
     Ziel : ZIELLAUFWERK:\Share

    Dateien : *.*
	    
  Optionen: *.* /TEE /S /E /DCOPY:DA /COPY:DATS /SECFIX /PURGE /MIR /R:5 /W:30 

AD Datenbank Repair - Versuche

Microsoft :
https://support.microsoft.com/de-at/help/258062.

Datenbank ad repair
https://www.tecchannel.de/a/active-directory-datenbank-pflegen-und-reparieren,435528,5

---
Datenbank repair

https://www.tecchannel.de/a/active-directory-sichern-wiederherstellen-und-warten,2040204,6

Praxis für Windows Server 2012 und 2012 R2
Active Directory - sichern, wiederherstellen und warten
Artikel empfehlen:

Kommentare & Drucken:

Autor:
08.04.2014Von Thomas Joos (Autor) 
Active-Directory-Datenbank reparieren

Zuweilen kann es vorkommen, dass die Active-Directory-Datenbank nicht mehr funktioniert. Gehen Sie bei einem solchen Problem folgendermaßen vor:

    Starten Sie den Server im Verzeichnisdienstwiederherstellung-Modus, oder beenden Sie Active Directory mit net stop ntds.

    Öffnen Sie eine Befehlszeile und starten Ntdsutil.exe.

    Geben Sie anschließend den Befehl activate instance ntds ein.

    Geben Sie files ein, um zu file maintenance zu gelangen.

    Geben Sie integrity ein, um einen Integritätstest der Datenbank durchzuführen. Wenn dieser Test eine Fehlermeldung anzeigt, können Sie versuchen, die Datenbank in Ntdsutil.exe zu retten.

    Verlassen Sie mit quit die file maintenance, aber bleiben Sie in der Oberfläche von Ntdsutil.exe.

    Geben Sie den Befehl semantic database analysis ein.

    Geben Sie zunächst den Befehl verbose on ein, damit Sie detaillierte Informationen erhalten.

    Geben Sie als Nächstes den Befehl go fixup ein.

CSV - Bulk User Batch Import mit Passwort definiert für alle (create_user.bat)

  • Analog zu create_user_text_csv.bat - nur Passwörter sind für alle gleich und definiert + SCRIPT Pfad wird angegeben + Passwort muss nach 1. Login geändert werden
@echo off

set pass=PASSWORD_ALLE_USER
set scriptpath=SCRIPT.BAT


set list_users=liste.txt
set error_list=user-error.csv
set success_list=user-success.csv

echo accountUsername;gruppe;beschreibung> %error_list%
echo accountUsername;gruppe;beschreibung> %success_list%

for /f "tokens=1,2 delims=;" %%f in (%list_users%) DO (

net user %%f 1> nul 2>&1

if %ERRORLEVEL% EQU 2 (
	net user %%f %pass% /add /active:yes /passwordchg:yes /scriptpath:%scriptpath% /Y /DOMAIN 1> nul 2>&1
    
	 
	if %ERRORLEVEL% EQU 2 (
		echo Successfully created: %%f
		net group %%g 1> nul 2>&1
		
		if %ERRORLEVEL% EQU 2 ( net group %%g /add /DOMAIN 1> nul 2>&1 )
		
		net group %%g %%f /ADD /DOMAIN 1> nul 2>&1
		
		if %ERRORLEVEL% EQU 2 ( echo Successfully added: %%f to group: %%g 
		                        echo %%f;%%g;Complete Success >> %success_list% ) else ( echo FAIL: Couldn't add %%f to group %%g 
								                                                    echo %%f;%%g;User created couldn't be added to group >> %error_list%)
	) else ( echo FAIL: Couldn't add user %%f  
	         echo "%%f;%%g;User couldn't be added" >> %error_list% )
) else ( echo FAIL: User: %%f already available manual intervention needed 
         echo %%f;%%g;User already available >> %error_list% )

)
pause

CSV - Bulk Prüfungs User Batch import (create_user_test_csv.bat)

  • Es existiert eine GPO die für User mit der Mitgliedschaft zu zB: pruefung aktiv wird
  • Achtung 2xMal ausführen - Vielleicht Environment beim 1. Mail Ausführung nicht korrekt / ERRORLEVEL ?
  • CSV Datei im gleichen verzeichnis - user-liste-test.txt mit Liste der zu erstellenden Benutzernamen und der Gruppenzugehörigkeit
user01;pruefung
user02;pruefung
user03;pruefung
  • create_user_test_csv.bat
@echo off

set list_users=user-liste-test.txt
set error_list=user-error.csv
set success_list=user-success.csv
echo accountUsername;gruppe;beschreibung > %error_list%
echo accountUsername;gruppe;passwort;beschreibung > %success_list%

for /f "tokens=1,2 delims=;" %%f in (%list_users%) DO (

net user %%f 1> nul 2>&1

if %ERRORLEVEL% EQU 2 (
        setlocal EnableDelayedExpansion
        set /a pass="!RANDOM!+10000000+!RANDOM!*1000"
   	net user %%f !pass! /add /active:yes /passwordchg:no /Y /DOMAIN 1> nul 2>&1
 
	if %ERRORLEVEL% EQU 2 (
		echo Successfully created: %%f
		net group %%g 1> nul 2>&1
		
		if %ERRORLEVEL% EQU 2 ( net group %%g /add /DOMAIN 1> nul 2>&1 )
		
		net group %%g %%f /ADD /DOMAIN 1> nul 2>&1
		
		if %ERRORLEVEL% EQU 2 ( echo Successfully added: %%f to group: %%g 
		                        echo %%f;%%g;!pass!;Complete Success >> %success_list% ) else ( echo FAIL: Couldn't add %%f to group %%g 
								                                                    echo %%f;%%g;!pass!;User created couldn't be added to group >> %error_list%)
	) else ( echo FAIL: Couldn't add user %%f  
	         echo "%%f;%%g;User couldn't be added" >> %error_list% )
) else ( echo FAIL: User: %%f already available manual intervention needed 
         echo %%f;%%g;User already available >> %error_list% )

)


pause
  • user-error.csv user-success.csv werden erstellt im gleichen Verzeichnis - in der success Datei befindet sich auch das „generierte“ Passwort für die Prüfungsbenutzer
  • Die User selbst werden bei einem AD Server in der OU „USERS“ abgelegt

Ordner kopieren (per GPO oder psexec)

  • Beispielaufruf: robocopy_copy.bat \\fileserver\Software-big\ C:\Software-big\ C:\copy_software_big.txt
  • Kann auch als GPO (Computer Startup) genutzt werden / Parameter über Reiter „Parameter“ hinzufügen
  • Achtung /mir spiegel alles vom Ursprung , die Parameter immer überprüfen!!
  • robocopy_copy.bat
echo off
set fromLocation=%1
set toLocation=%2
set toLogfile=%3

IF %1.==. GOTO Usage
IF %2.==. GOTO Usage
IF %3.==. GOTO Usage


if exist "%toLogFile%" goto Ende
if not exist "%toLocation%" mkdir %toLocation%


robocopy /MIR /R:2 /W:2 %fromLocation% %toLocation%

if %ERRORLEVEL% EQU 0 echo "finished_successfully" > %toLogfile%

exit 0

:Usage
echo "%0 fromLocation toLocation logFile
echo ---------------------------
echo Beispielaufruf: %0 \\file\Software\ C:\Software\ C:\copy_software.txt
exit 2

:Ende
exit 0 

NTFS Ownership ändern

  • Getestet auf Windows 2012r2 Standard als Domain Administrator der eine User Ownership vergibt
https://stackoverflow.com/questions/20673599/change-owner-and-permissions-on-folder#20676221

To make an addition to permissions and:

icacls.exe d:\test /setowner domain\username

To set ownership. Other options of interest from icacls /?:

/T indicates that this operation is performed on all matching
    files/directories below the directories specified in the name.

/C indicates that this operation will continue on all file errors.
    Error messages will still be displayed.

NTFS Volume verkleinern

  • Gegeben: 1.5TB Volume das auf 500GB verkleinert werden soll und bereits seit Jahren existiert
  • FAIL:
    • Restore Punkte deaktivieren & löschen - hat nichts gebracht
    • SWAP Speicher Konfiguration ändern - auf manuell gestellt und auf dem Volume gibts keinen SWAP - hat nichts gebracht
    • Windows internes defrag zahlreiche Male ausgeführt - hat nichts gebracht - offenbar nicht verschiebbare Dateien die nicht identifizierbar sind
    • Möchte kein neues Volume per SCSI hinzufügen und alle Shares neu definieren müssen bzw. nicht genug Speicherplatz für Kopie verfügbar
    • Windows Ansatz zum verkleinern:
To shrink a basic volume using a command line

    Open a command prompt and type diskpart.

    At the DISKPART prompt, type list volume. Note the number of the simple volume you want to shrink.

    At the DISKPART prompt, type select volume <volumenumber>. Selects the simple volume volumenumber you want to shrink.

    At the DISKPART prompt, type shrink [desired=<desiredsize>] [minimum=<minimumsize>]. Shrinks the selected volume to desiredsize in megabytes (MB) if possible, or to minimumsize if desiredsize is too large.

DHCP Server auslesen ohne powershell

Once i had the file in csv, i simply imported it into an excel sheet using spaces as the delimiter and hey presto a lovely little reservation report:

Same rules as always, dont run it from a UNC path, copy it local to the DHCP server and run it there.

netsh dhcp server dump >> reservationdump.txt
find “Add reservedip” reservationdump.txt >> reservations.csv

You can download the script as is here:
This script almost works as well. It currently lists extra clients. Some regex magic with the find command parameters could fix this. Save to to a .cmd file and specify your dhcppserver and a valid scope.

for /f "skip=4 delims=: tokens=2" %%a in ('nslookup %1') do set IP=%%a
netsh dhcp server \\ourdhcpsvr scope 192.168.1.0 show clients|findstr "%IP%"

Output should look like this

172.16.19.78     - 255.255.248.0  - c6-33-5f-cb-a7-a5   -4/25/2017 8:26:07 AM   -D

Computer Liste auslesen aus AD dsquery

Say you want to find out which computers will be affected if you link a GPO to a certain OU. You could run the following dsquery command:
dsquery computer "OU=IT,DC=contoso,DC=com" -o rdn
1
	
dsquery computer "OU=IT,DC=contoso,DC=com" -o rdn

The result would be a list of computer names. If you omit the -o switch with the rdn value, you receive a list of Distinguished Names.

Windows generell Dateien löschen

  • zB: in einem Verzeichnis mehr als 1Mio Dateien
  • Löschen über Explorer shift → ENTF
    • Er schafft es nicht die korrekte Anzahl der Dateien zu berechnen und auch nicht die Dauer des Löschvorgangs
  • Löschen über cli:
The best I've found is a two line batch file with a first pass to delete files and outputs to nul to avoid the overhead of writing to screen for every singe file. A second pass then cleans up the remaining directory structure:

del /f/s/q foldername > nul
rmdir /s/q foldername

Windows home-verzeichnisse erstellen

  • Falls auf home verzeichnisse verwiesen wird die nicht existieren / mit diesem Skript können Sie unter angabe der entsprechenden OU / und Domain Servers angelegt werden
#####################################################################
# AUTHOR  : Victor Ashiedu 
# DATE    : 01-10-2014
# WEB     : iTechguides.com
# BLOG    : iTechguides.com/blog
# COMMENT : This PowerShell script creates a home folder for all users in Active Directory   
#           (Accessed only by the user) If this script was helpful to you, 
#           please take time to rate it at: http://gallery.technet.microsoft.com/PowerShell-script-to-832e08ed
#####################################################################
############################VERY IMPORTANT:##########################

#before you run this script enure that you read the ReadMe text file
######################################################################

#This script has the following functionalities:#######################

#1 Creates a persoanl (home folder) for all AD users 
#2 Provides option to create users folders as DisplayName or sAMAccountname (Log on name) 
#3 Grants each users "Full Control" to his or her folder
#4 Maps the users folder as drive 'H' (Configured via AD Users property, 
#5 Ensures that users canot access another user's folder

#######################################################################
#######################################################################

#BEGIN SCRIPT

#Define variable for a server to use with query.
#This might be necessary if you operate in a Windows Server 2003 Domain
# and have AD web services installed in a particular DC

$ADServer = ad.schule.intern' 


#Get Admin accountb credential

$GetAdminact = Get-Credential 

#Import Active Directory Module

Import-Module ActiveDirectory

#define search base - the OU where you want to 
# search for users to modify. you can define the 
#domain as your searchbase
#add OU in the format OU=OU 1,Users OU,DC=domain,DC=com

$searchbase = "OU=Benutzer,DC=DOMAIN,DC=COM" 

#Search for AD users to modify

$ADUsers = Get-ADUser -server $ADServer -Filter * -Credential $GetAdminact -searchbase $searchbase -Properties *


ForEach ($ADUser in $ADUsers) 
{

#$ADUser -properties SamAccountName | Format-List

#$ADUser | Select-Object -Property SamAccountName,homedirectory | Format-List

[string]$pathHomeDirectory = $( $ADUser.homedirectory )

if ( -not ( Test-Path $pathHomeDirectory ) )
{
write-host("--------");
write-host("Home Directory not found: "+$path);
write-host("AccountName: "+$ADUser.samAccountName);

#Create Missing directory
$homeShare = New-Item -path $pathHomeDirectory -ItemType Directory -force -ea Stop



 $acl = Get-Acl $homeShare

    $FileSystemRights = [System.Security.AccessControl.FileSystemRights]“Modify“
    $AccessControlType = [System.Security.AccessControl.AccessControlType]::Allow
    $InheritanceFlags = [System.Security.AccessControl.InheritanceFlags]“ContainerInherit, ObjectInherit“
    $PropagationFlags = [System.Security.AccessControl.PropagationFlags]“InheritOnly“

    $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ($ADUser.SID, $FileSystemRights, $InheritanceFlags, $PropagationFlags, $AccessControlType)
    $acl.AddAccessRule($AccessRule)

    Set-Acl -Path $homeShare -AclObject $acl -ea Stop

    Write-Host („HomeDirectory created at {0}“ -f $homeShare)
write-host("--------");

}


}
#END SCRIPT
  

Windows 2016 Ressourcen Manager f. Quotas

  • Installation auf Dateiserver über damischen ServerManager

  • Link zum Ressourcen Manager: %windir%\system32\mmc.exe %windir%\system32\fsrm.msc
  • zB: Harte Grenze mit 2TB auf ganzes Laufwerk mit E-Mail Notifikation ( SMTP Server kann über Rechtsklick - Ressourcen-Manager - Optionen konfigurieren eingestellt werden / natürlich ohne user auth zumindests in GUI)

  • Achtung: er benötigt einige Zeit um das Kontingent zu berechnen und den Verbrauch in der Zeit „stimmt“ der freie und verbrauchte Speicher NICHT

Windows 2012r2 to Windows 2019 Upgrade

  • Achtung wird nicht empfohlen ABER dieser Upgrade Pfad wird grundsätzlich unterstützt
  • Getestet auf/mit: Restore Offline Backup von Altaro auf hyper-v Server, Betroffener 2012r2 Server mit folgenden Rollen: AD/DNS/DHCP/WDS / 2. AD Server wurde hart entfernt für den Test des Offline Upgrades
  • setup.exe des 2019er ISOS aufrufen

  • Achtung Adconnect V1.x läuft nicht mehr auf 2019 / WDS startet nicht mehr - Verzeichnisse für ARM anlegen dann funktionierts
  • Achtung Update hängt bei 91% bei minimaler IO Tätigkeit und minimaler CPU Auslastung / nach >1 Stunde wurde das Upgrade trotzdem fertig gestellt
  • Achtung nach Bereinigung dieser Issues kommt noch eine Überprüfung der vorhandenen Programme auf Kompatiblität - sollten hier Programme auftauchen die nicht kompatibel sind müssen die Programme entfernt bzw. bereinigt werden sonst ist das Setup stuck / Mit https://docs.microsoft.com/en-us/sysinternals/downloads/procmon lässt sich überprüfen welche Checks durchgeführt werden - Microsoft ruttelt hier alle Laufwerke durch und sucht nach „hardcoded“ Verzeichnisnamen zB: „Update Services“

Windows 2012r2 Powershell TLS troubles

  • ein besonders tolles Schmankerl / Diverse Versuche „NuGet“ Provider zu installieren schlugen fehl - Kontrolle auf dem Proxy ergab verdächtige Paketgrößen bei CONNECT Analyse
  • Wireshark Dump des TLS Hanshakes zeigte, dass Microsoft die Unterstützung für TLS1 (oder auch 1.1 FIXME) deaktiviert hat - es muss mit zumindest TLS 1.2 zugegriffen werden
 Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
WARNUNG: MSG:UnableToDownload
«https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»
WARNUNG: Die Liste der verfügbaren Anbieter kann nicht heruntergeladen werden.
Überprüfen Sie Ihre Internetverbindung.
WARNUNG: Es kann kein Download von URI
"https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409" nach ""
durchgeführt werden.
Install-PackageProvider : Für die angegebenen Suchkriterien für Anbieter
"NuGet" wurde keine Übereinstimmung gefunden. Der Paketanbieter erfordert das

TLS V1 Alert Errors - Wireshark 


PS C:\Users\administrator.SCHULE.000> [System.Net.ServicePointManager]::Security
Protocol =  [System.Net.SecurityProtocolType]::Tls12
PS C:\Users\administrator.SCHULE.000> Install-PackageProvider -Name NuGet -Minim
umVersion 2.8.5.201 -Force

Name                           Version          Source           Summary
----                           -------          ------           -------
nuget                          2.8.5.208        https://onege... NuGet provi...

Windows 2012r2 Azure AD High Load

Stop the Azure AD Connect Health Sync Monitor Service

The first option is to stop the Azure AD Connect Health Sync Monitor service and set it to manual until the updated utility is released.

    Click on Start and search for Services
    Find the Azure AD Connect Health Sync Monitor service
    Right click on it and click Stop
    Right click on the same service and go to Properties
    Change the Startup Type to Manual

GPO 1607 - Templates Problem

  • Blabla Geo Location error „Fehler „‚Microsoft.Policies.Sensors.WindowsLocationProvider‘ ist bereits definiert““
https://support.microsoft.com/de-at/help/3077013/microsoft-policies-sensors-windowslocationprovider-is-already-defined


Methode 2
Löschen Sie die Dateien „LocationProviderADM.admx“ und „LocationProviderADM.adml“, und ändern Sie „Microsoft-Windows-Geolocation-WLPAdm.admx“ und „Microsoft-Windows-Geolocation-WLPAdm.adml“ in die richtigen Namen.

Szenario 1

    Löschen Sie die Dateien „LocationProviderADM.admx“und „LocationProviderADM.adml“ aus dem zentralen Speicher.
    Benennen Sie „Microsoft-Windows-Geolocation-WLPAdm.admx“ um in „LocationProviderADM.admx“.
    Benennen Sie „Microsoft-Windows-Geolocation-WLPAdm.adml“um in „LocationProviderADM.adml“.

Szenario 2

    Löschen Sie die Datei „Microsoft-Windows-Geolocation-WLPAdm.admx“ aus dem lokalen Speicher. Der Pfad zum lokalen Richtlinienspeicher lautet „C:\Windows\PolicyDefinitions“.

Windows Update Cli

  • Cli
    wuauclt  /DetectNow
    Jetzt nach Updates suchen.
    wuauclt  /ReportNow
    Nicht berichtete Probleme an Microsoft melden.
    wuauclt  /ShowSettingsDialog
    Windows-Update-Einstellungen anzeigen.
    wuauclt  /ResetAuthorization
    Update-Komponenten zurücksetzen.
    wuauclt  /ResetEulas
    Bestätigung der Lizenzverträge erneut einholen.
    wuauclt  /ShowWU
    Windows-Update anzeigen.
    wuauclt  /ShowWindowsUpdate
    Windows-Update anzeigen.
    wuauclt  /SelfUpdateManaged
    wuauclt  /SelfUpdateUnmanaged
    wuauclt  /UpdateNow
    Verfügbare Updates installieren.
    wuauclt  /ShowWUAutoScan
    wuauclt  /ShowFeaturedUpdates
    wuauclt  /ShowOptions
    wuauclt  /ShowFeaturedOptInDialog
    wuauclt  /DemoUI
  • Windows 10 Windows Update Logs oho natürlich net mehr windowsUpdate.log Happy Powershell
C:\Users\christian.czeczil>powershell
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. Alle Rechte vorbehalten.

PS C:\Users\christian.czeczil>  Get-WindowsUpdateLog

Converting C:\Windows\logs\WindowsUpdate into C:\Users\christian.czeczil\Desktop\WindowsUpdate.log ...


    Verzeichnis: C:\Users\CHRIST~1.CZE\AppData\Local\Temp\WindowsUpdateLog


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       04.07.2018     11:31                SymCache

Eingabe
----------------
Datei(en):
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20180626.173314.738.1.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20180626.190715.973.1.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20180626.204114.477.1.etl
     C:\Windows\logs\WindowsUpdate\WindowsUpdate.20180626.221514.107.1.etl
 Standardmäßig verzeichnet der Windows Update-Client sämtliche Transaktionsinformationen in folgender Protokolldatei:
%windir%\Windowsupdate.log
Wenn auf der Microsoft Windows Update-Website oder vom Dienst für automatische Updates eine Fehlermeldung ausgegeben wird, können Sie das Problem mithilfe der in der Protokolldatei "Windowsupdate.log" enthaltenen Informationen beheben.
  • Windows Updates Hack - neu intialisieren am Client
CMD (als Admin)
net stop wuauserv
net stop bits
rd /s /q %windir%\SoftwareDistribution
del %windir%\WindowsUpdate.log
net start wuauserv
net start bits
wuauclt /resetauthorization /detectnow
wuauclt /reportnow
UsoClient.exe

StartScan
StartDownload
StartInstall
RestartDevice

GPO - interaktives Batch Skript

  • Sollten die User bei einem User Skript befragt werden müssen d.h. interaktiv
  • In diesem Zweig befinden sich die entsprechenden GPO Einstellungen um batch Skript sichtbar zu machen Anweisungen in Anmeldeskripts während der Ausführung anzeigen

echo Hast du die Lizenz eingegeben und sie wurde akzeptiert ? ( j/n )
:Frage
SET /p wahl=
if /i not '%wahl%' == 'n' (if /i '%wahl%' == 'j' (goto Ja ) ) else goto Nein 
if defined wahl ECHO Bitte mit j fuer Ja oder n fuer Nein. antworten. Vielen Dank & goto Frage

:Nein
goto Ende
:Ja
echo success > C:\license.log
:Ende

GPO für bestimmte Windows Versionen (WMI)

To create a WMI filter that queries for a specified version of Windows

    Open the Group Policy Management console.

    In the navigation pane, expand Forest: YourForestName, expand Domains, expand YourDomainName, and then click WMI Filters.

    Click Action, and then click New.

    In the Name text box, type the name of the WMI filter.

        Note: Be sure to use a name that clearly indicates the purpose of the filter. Check to see if your organization has a naming convention.

    In the Description text box, type a description for the WMI filter. For example, if the filter excludes domain controllers, you might consider stating that in the description.

    Click Add.

    Leave the Namespace value set to root\CIMv2.

    In the Query text box, type:
    syntax 

select * from Win32_OperatingSystem where Version like "6.%"

This query will return true for devices running at least Windows Vista and Windows Server 2008. To set a filter for just Windows 8 and Windows Server 2012, use "6.2%". For Windows 10 and Windows Server 2016, use "10.%". To specify multiple versions, combine them with or, as shown in the following:
syntax

... where Version like "6.1%" or Version like "6.2%"

To restrict the query to only clients or only servers, add a clause that includes the ProductType parameter. To filter for client operating systems only, such as Windows 8 or Windows 7, use only ProductType="1". For server operating systems that are not domain controllers, use ProductType="3". For domain controllers only, use ProductType="2". This is a useful distinction, because you often want to prevent your GPOs from being applied to the domain controllers on your network.

The following clause returns true for all devices that are not domain controllers:
syntax

... where ProductType="1" or ProductType="3"

The following complete query returns true for all devices running Windows 10, and returns false for any server operating system or any other client operating system.
syntax

select * from Win32_OperatingSystem where Version like "10.%" and ProductType="1"

The following query returns true for any device running Windows Server 2016, except domain controllers:
syntax

select * from Win32_OperatingSystem where Version like "10.%" and ProductType="3"

Click OK to save the query to the filter.

Click Save to save your completed filter.

Hyper-V Storage Offline

  • Besonders erfreulich wenn der Server (2012r2) neu bootet und das Storage Volume nicht online nimmt obwohl es ein lokales RAID Controller Volume ist / auf dem alle virtuellen Maschinen liegen
  • SAN Policy wurde auf „OnlineAll“ geändert
https://support.purestorage.com/Solutions/Microsoft_Platform_Guide/aaa_Quick_Setup_Steps/Step_04

Microsoft DiskPart-Version 6.3.9600

Copyright (C) 1999-2013 Microsoft Corporation.
Auf Computer: FOO

DISKPART> san

SAN-Richtlinie  : Offline - Freigegeben

DISKPART> SAN Policy=OnlineAll

Die SAN-Richtlinie für das aktuelle Betriebssystem wurde erfolgreich geändert.

DISKPART>

Hyper-V Storage Migration

  • Getestet auf Win2012r2 von einem SAS RAID Volume auf ein SSD RAID Volume im laufenden Betrieb

Hyper-V Replikation

https://www.andysblog.de/windows-hyper-v-replikat-uebersicht-anleitung-fuer-den-arbeitsgruppenbetrieb

  • Achtung CRL Check deaktivieren !!!
  • Achtung kann auch sein KEIN FQDN Name sondern nur über hostname replizieren !!!
  • Aktivieren der Replikation über Powershell cli:
Enable-VMReplication -VmName VM_NAME -ReplicaServerName FOFOFOFO -ReplicaServerPort fofofo -AuthenticationType Certificate -CertificateFingerprint FINGERPRINT 
  • Anleitung vom Blog - des is a Bursch:
Anleitung zu Hyper-V-Replikat in Arbeitsgruppen oder bei stand-alone Servern

Diese Anleitung bezieht sich auf zwei stand-alone Hyper-V Server 2012. Jeder Host ist in einer anderen Arbeitsgruppe. Für die Replikation kommt in dieser Konstellation nur die Authentifizierung mit Zertifikaten in Frage. Der Einfachheit halber werden selbstsignierte Zertifikate verwendet. Neben den zwei Hyper-V Servern wird eine Windows 8 Arbeitsstation für die Einrichtung und Verwaltung benötigt.
Windows 8

    Windows Software Development Kit (SDK) for Windows 8 herunterladen und installieren. Aus dem SDK wird das Tool „makecert.exe“ benötigt um die Zertifikate für die Hyper-V Hosts erstellen zu können. Dieses Tool auf die Hyper-V Hosts kopieren.
    Unter „Systemsteuerung – Programme und Funktionen – Windows-Funktionen aktivieren und deaktivieren – Hyper-V“ die „Hyper-V-Verwaltungstools“ aktivieren.
    HVRemote herunterladen.
    In einer Eingabeaufforderung mit erhöhten Rechten folgende Befehle ausführen:

cscript hvremote.wsf /anondcom:grant
cmdkey /add:HYPER-V-COMPUTERNAME /user:HYPER-V-COMPUTERNAME\Administrator /pass

Der cmdkey-Befehl muss für jeden Hyper-V angepasst und ausgeführt werden.
Hyper-V Server 2012

Auf allen Hyper-V Hosts muss die Remoteverwaltung aktiviert sein. Ferner sollten statische IP-Adressen konfiguriert werden. Damit die Firewall den Replikationsverkehr durchlässt muss folgender Befehl pro Host ausgeführt werden:

netsh advfirewall firewall set rule group="Hyper-V-Replikat - HTTPS" new enable=yes

Nachfolgend wird von einem primären und einem recovery Host ausgegangen. Bei den Befehlen muss „<FQDN>“ pro Host angepasst werden, z.B. „host1.test.local“.

Auf dem primären Host folgende Befehle ausführen:

makecert -pe -n "CN=PrimaryTestRootCA" -ss root -sr LocalMachine -sky signature -r "PrimaryTestRootCA.cer"

makecert -pe -n "CN=<FQDN>" -ss my -sr LocalMachine -sky exchange -eku 1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2 -in "PrimaryTestRootCA" -is root -ir LocalMachine -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 PrimaryTestCert.cer

Auf dem recovery Host folgende Befehle ausführen:

makecert -pe -n "CN=RecoveryTestRootCA" -ss root -sr LocalMachine -sky signature -r "RecoveryTestRootCA.cer"

makecert -pe -n "CN=<FQDN>" -ss my -sr LocalMachine -sky exchange -eku 1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2 -in "RecoveryTestRootCA" -is root -ir LocalMachine -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 RecoveryTestCert.cer

Nun muss die „*.CA.cer“-Datei auf den jeweils anderen Host kopiert werden. Auf dem primären Host wird das Zertifikat mit dem Befehl

certutil -addstore -f Root "RecoveryTestRootCA.cer"

importiert. Auf dem recovery Host wird das Zertifikat mit dem Befehl

certutil -addstore -f Root "PrimaryTestRootCA.cer"

importiert. Abschließend muss auf beiden Hosts der Befehl

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Replication" /v DisableCertRevocationCheck /d 1 /t REG_DWORD /f

ausgeführt werden.

Damit sind die Voraussetzungen für Hyper-V-Replikat erfüllt. Nun kann für alle gewünschten virtuellen Maschinen die Replikation konfiguriert werden. Dazu den Hyper-V-Manager auf der Windows 8 Arbeitsstation starten, beide Hyper-V Hosts hinzufügen und die jeweilige virtuelle Maschine mit der rechten Maustaste anklicken. Anschließend „Replikation aktivieren…“ auswählen und dem Assistenten folgen.

Wichtig dabei ist, das bei der Angabe des Replikatserver der FQDN verwendet wird, der NetBIOS-Name reicht nicht aus und führt zu einer Fehlermeldung!

Hyper-V Server 2019

  • Nach Replikation von 2012r2 auf 2019 Server
  • Achtung zur Migration von Hyper V Hosts die NICHT in einer Domäne sind - Replikation mit Zertifikaten nutzen
  • Generation 2 Maschinen können nicht mehr starten
  • Fehlermeldung:

  • Lösung MAC Adresse der Maschine auf neuem Server ändern

Hyper-V VLAN

  • Getestet auf Ubuntu 18.04 und Windows 2019 Host
  • Wollte VLANs direkt nativ im Linux konfigurieren / Es ist leider nur möglich entweder tagged (trunk) Pakete oder untagged (access) Pakete über den Host auf den Switch zu bringen
  • NativeVlanId bedeutet Pakete die von der linux Maschine untagged sind werden durch den Host mit der VLAN Id getagged d.h. am Switch nur tagged Pakete / Untagged ist die Default Konfiguration
PS C:\Users\Administrator> Set-VMNetworkAdapterVLAN -VMName PLAY -Trunk -AllowedVlanIDList 1-500 -NativeVlanId 1
PS C:\Users\Administrator> Set-VMNetworkAdapterVLAN -VMName PLAY  -Untagged
  • Gezielt gewisse Tagged VLANs an den Switch weiter geben zB: VLAN10 am Switch / wird als eigene „Netzwerkkarte“ hinzugefügt mit Identifikation des VLAN's - Linux sieht eine „normale“ Netzwerkkarte das Tagging übernimmt das Hostsystem

Windows Proxy einstellungen

  • Auto detection für aktuell eingeloggten Benutzer (mit zB: WPAD und PAC File per DHCP):
You can do it with this:

    To Enable 'Automatically Detect Settings'

    REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoDetect /t REG_DWORD /d 1 /f

    To Disable 'Automatically Detect Settings'

    REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoDetect /t REG_DWORD /d 0 /f

  • WinHTTP Komponente: (zB: .NET Applikationen)

The proxy settings for WinHTTP are not the proxy settings for Microsoft Internet Explorer.
You cannot configure the proxy settings for WinHTTP in the Microsoft Windows Control Panel.
Using the WinHTTP proxy configuration utility does not alter the settings you use for Internet Explorer.

To configure a system wide proxy do

netsh winhttp set proxy myproxy

source: http://technet.microsoft.com/pt-br/library/cc731131(v=ws.10).aspx#BKMK_5

if you want to use IE proxy settings for all programs, try

netsh winhttp import proxy source =ie

source: http://technet.microsoft.com/pt-br/library/cc731131(v=ws.10).aspx#BKMK_2

more information here:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384069(v=vs.85).aspx

Windows 2012r2 Update Fehler

Am 06.08.2015 schrieb Woly:

    ein frisch installierter Server 2012 R2 Essentials meldet bei der Suche nach Updates den Fehler 80244019. Dieser Fehlercode scheint häufiger in Verbindung mit WSUS aufzutreten, aber weder führt dieser Server einen WSUS aus, noch hängt er an einem WSUS. Die Verbindung "nach draußen" wird durch einen handelsüblichen DSL-Router gewährleistet und auch nicht eingeschränkt.

In einer administrativen Commandline diese Befehle ausführen und anschließend den Server komplett neu starten.

net stop wuauserv
rd /s /q %windir%\SoftwareDistribution
del %windir%\WindowsUpdate.log
net start wuauserv

Nach dem Neustart auf Windows Update manuell nach Updates suchen
lassen. Das kann beim ersten Mal auch etwas länger dauern.

Windows DNS Server - Linux dig formErr

https://kevinlocke.name/bits/2017/01/20/formerr-from-microsoft-dns-server-for-dig/

DIG requested kevinlocke.name and received FORMERR. After some trial and error, I determined that the issue results from DIG 9.11 sending the DNS COOKIE option. This option was enabled by default in BIND 9.11. Unfortunately, adding this option causes DNS Server to treat the request as malformed. This behavior appears to violate “Any OPTION-CODE values not understood by a responder or requestor MUST be ignored.” from Section 6.1.2 of RFC 6891, but that is of small consolation for a non-working system.

-> As a workaround, pass the +nocookie option (or +noedns to disable all EDNS options) as in 

Windows DNS Server Blacklist

Removing WPAD from DNS block list

The DNS Server role in Windows Server 2008 introduces a global query block list to reduce vulnerability associated with dynamic DNS updates. For more information, see About implementing WPAD.

If you want to use WPAD with DNS, note the following:

    If WPAD entries are configured in DNS before the DNS server is upgraded in Windows Server 2008, no action is required.
    If you configure or remove WPAD after you deploy the DNS server role on a server running Windows Server 2008, you must update the block list on all DNS servers that host the zones affected by the change. The affected zones are those where you registered the WPAD servers.

Updating the block list

Use the dnscmd command-line tool to manage the global query block list. Open a command line prompt, and then do the following:

    To check whether the global query block is enabled, type the following:
    dnscmd /info /enableglobalqueryblocklist
    To display the host names in the current block list, type the following:
    dnscmd /info /globalqueryblocklist
    To disable the block list and ensure that the DNS Server service does not ignore queries for names in the block list, type the following:
    dnscmd /config /enableglobalqueryblocklist 0
    To enable the block list and ensure that the DNS Server service ignores queries for names in the block list, type the following:
    dnscmd /config /enableglobalqueryblocklist 0
    To remove all names from the block list, type the following:
    dnscmd /config /globalqueryblocklist
    To replace the current block list with a list of the names that you specify, type the following:
    dnscmd /config /globalqueryblocklist name [name]…

For more information and instructions, see the document "DNS Server Global Query Block List", available for download from Domain Name System at Microsoft TechNet.

VHD into WIM konvertieren

 19
down vote
accepted
	

Absolutely, let's post a prim and proper answer for Google. This is a simple 2 command Powershell execution, using the dism module. The dism can be copied to earlier versions of Windows, provided you have the appropriate version of the windows management framework.

First, mount the vhd using

Mount-WindowsImage -ImagePath C:\VHDs\BigHomies.vhdx -Path C:\VHDMount -Index 1

Then, capture it into a wim with

New-WindowsImage -CapturePath C:\VHDMount -Name Win7Image -ImagePath C:\CapturedWIMs\Win7.wim -Description "Yet another Windows 7 Image" -Verify

And let it do it's thing. When you are done you can unmount the vhd and discard any changes using:

Dismount-WindowsImage -Path C:\VHDMount -Discard

Windows Dienste f. User

C:\Program Files (x86)\Windows Resource Kits\Tools>subinacl /SERVICE \\PLAY-PC-2
\joomlaApache /GRANT=schule.intern\Lehrer=F

subinacl /SERVICE \\PLAY-PC-2\joomlaApache /GRANT=schule.intern\Schueler=F

C:\Users\Administrator>subinacl /service joomlaApache /grant="schule.intern\Dom�nen-Benutzer=F"

C:\Program Files (x86)\Windows Resource Kits\Tools

DHCP Server

UEFI/LEGACY PXE BOOT WDS Options

  • Getestet auf Windows 2022
  • Sollten sich DHCP und WDS Server auf der gleichen Maschine befinden setzt der WDS Dienst unter dem Häckchen DHCP-Optionen konfigurieren alle notwendigen Optionen (DHCP Option 60) für den DHCP Server die für PXE Booten sowohl Legacy als auch UEFI notwendig sind

  • Sollte sich der DHCP Server auf einem anderen Server befinden kann mit folgenden Optionen zum Windows WDS Server verwiesen werden - in diesem Beispiel befindet sich der WDS Server auf dem Server 10.0.0.2 (Option 66 und Option 67) - LEGACY Boot

  • Für den Verweis über UEFI PXE Boot ist der Aufwand schon größer - es muss eine eigene Herstellerklasse definiert werden und bei einem Match werden die Optionen 66 und 67 mit geändertem Inhalt an den Client verschickt:
  • bei den DHCP Einstellungen unter IPV4 Herstellerklassen - Hinzufügen:

UEFI ipxe MENÜ Option

  • Im Default Binary , das herunter geladen werden kann fragt das ipxe EFI Binary nach dem Menüpfad um ihn als DHCP Antwort zu erhalten

WDS/Windows/WSUS Server

  • Lenovo G2 ITL - Disk nicht gefunden bei WDS - Von VMD auf AHCI umstellen
  • WDS Fehler - Imagegröße ändert sich nicht in der GUI - Treiber werden NICHT hinzugefügt obwohl alles OK scheint
  • Lösung → INDEX:2
E:\TMP\dism-windows-10>.\Dism.exe -Mount-Wim -WimFile:E:\TMP\Windows10_1607_64Bi
t_verteilen.wim -Index:2 -MountDir:E:\TMP-Mount

Deployment Image Servicing and Management tool
Version: 10.0.16299.15

Abbild wird bereitgestellt
[==========================100.0%==========================]
The operation completed successfully.

E:\TMP\dism-windows-10>.\dism -Image:E:\TMP-Mount -Add-Driver -Driver:E:\Treiber
\HP-800-G4-SFF\hp-800-g4-intel-nic-sp98256\src /Recurse

Deployment Image Servicing and Management tool
Version: 10.0.16299.15

Image Version: 10.0.14393.0

Suche nach zu installierenden Treiberpaketen...
Anzahl der zu installierenden Treiberpakete: 2.
1 von 2 - E:\Treiber\HP-800-G4-SFF\hp-800-g4-intel-nic-sp98256\src\E1D\e1d68x64.
inf wird installiert:
INFO: DISM hat die Überprüfung der Treibersignatur übersprungen, weil die Versio
nen des ausgeführten Betriebssystems und des Zielbetriebssystems nicht übereinst
immen.
Das Treiberpaket wurde erfolgreich installiert.
2 von 2 - E:\Treiber\HP-800-G4-SFF\hp-800-g4-intel-nic-sp98256\src\E1R\e1r68x64.
inf wird installiert:
INFO: DISM hat die Überprüfung der Treibersignatur übersprungen, weil die Versio
nen des ausgeführten Betriebssystems und des Zielbetriebssystems nicht übereinst
immen.
Das Treiberpaket wurde erfolgreich installiert.
The operation completed successfully.

E:\TMP\dism-windows-10>.\Dism -Commit-Wim -MountDir:E:\TMP-Mount

Deployment Image Servicing and Management tool
Version: 10.0.16299.15

Abbild wird gespeichert
[==========================100.0%==========================]
The operation completed successfully.

E:\TMP\dism-windows-10>.\Dism -Unmount-Wim -Commit -MOuntDir:E:\TMP-Mount

Deployment Image Servicing and Management tool
Version: 10.0.16299.15

Abbilddatei: E:\TMP\Windows10_1607_64Bit_verteilen.wim
Abbildindex: 2
Abbild wird gespeichert
[==========================100.0%==========================]
Bereitstellung des Abbilds wird aufgehoben
[==========================100.0%==========================]
The operation completed successfully.
  • Bei sysprep Fehler:
https://social.technet.microsoft.com/Forums/windows/en-US/c469805c-98af-4bb2-9655-c86c294470a9/sysprep-failure-occurred-while-executing-drmv2cltdll-fix?forum=w7itproinstall:

Click Start > Run, type Services.msc to open the Services applet.
Scroll down to Windows Media Player Network Sharing Service, double click it, change the Startup type to Disabled.  Click OK.
Reboot the PC
  • WDS Treiberproblem Fehler 30 bei nivida:
Bei Fehler 30 nvidia treiber: expand *.* .\test\ -> dann kommt wurde vergrößert xy prozent und dann gehts im test verzeichnis

siehe WDS deadaffebeef magic darunter für treiber hinzufügen
  • WDS am Server - Image mounten & gucken
http://deadaffebeef.com/blog/wds-windows-updates-treiber-zu-wim-abbild-hinzufugen/

1) Das Installationsabbild, welchem weitere Pakete hinzugefügt werden sollen, muss zu allererst exportiert werden:

CMD (als Administrator ausführen!): wdsutil -Export-Image -Image:”Win7 x86 ENT” -ImageType:Install -ImageGroup:Win7 -DestinationImage -FilePath:D:\Win7x86ENT.wim -Overwrite:Yes

2) Als nächstes muss die WIM-Datei gemountet werden:

dism -Mount-Wim -WimFile:D:\Win7x86ENT.wim -Index:1 -MountDir:D:\Mount

3) Nun können die Update- (CAB oder MSU) bzw. Treiber-Pakete dem gemounteten Image hinzugefügt werden:

Windows Updates: dism -Image:D:\Mount -Add-Package -PackagePath:<Pfad_und_Dateiname> /Recurse

Treiber: dism -Image:D:\Mount -Add-Driver -Driver:<inf-Pfad_OHNE_Dateiname>

4) Die vorgenommenen Änderungen am Image müssen gespeichert werden:

dism -Commit-Wim -MountDir:D:\Mount

5) Bevor das neue Image im WDS eingebunden werden kann, muss es zunächst unmountet werden:

dism -Unmount-Wim -Commit -MountDir:D:\Mount

6) Jetzt noch das ursprüngliche Installationsabbild durch das angepasste ersetzen und wir sind fertig:

wdsutil -Replace-Image -Image:”Win7 x86 ENT” -ImageType:Install -ImageGroup:Win7 -ReplacementImage -ImageFile:D:\Win7x86ENT.wim

Alternativ kann das geänderte Image als neues Abbild im WDS eingebunden werden:

wdsutil -Add-Image -ImageType:Install -ImageGroup:Win7 -ImageFile:D:\Win7x86ENT.wim -SingleImage:”Win7 x86 Enterprise” -Name:”Win7 x86 ENT” -Description:”Win7 x86 ENT Image – neu”

  • Zeit reparieren NTP:
http://blogs.technet.com/b/nepapfe/archive/2013/03/01/it-s-simple-time-configuration-in-active-directory.aspx 

AT Pool:

	   server 0.at.pool.ntp.org
	   server 1.at.pool.ntp.org
	   server 2.at.pool.ntp.org
	   server 3.at.pool.ntp.org


zB:
llten Sie eine neuere Version von Windows einsetzten, können Sie den NTP-Client nutzen, der in das System integriert ist. Führen Sie dazu folgendes Kommando als Administrator aus: 
w32tm /config /syncfromflags:manual /manualpeerlist:"0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org"



Status:
C:\Users\administrator.SCHULE.000>w32tm /query /status
Sprungindikator: 0(keine Warnung)
Stratum: 2 (Sekundärreferenz - synchr. über (S)NTP)
Präzision: -6 (15.625ms pro Tick)
Stammverzögerung: 0.0000000s
Stammabweichung: 0.0100000s
Referenz-ID: 0x564D5450 (Quell-IP:  86.77.84.80)
Letzte erfolgr. Synchronisierungszeit: 24.06.2015 11:07:00
Quelle: VM IC Time Synchronization Provider
Abrufintervall: 6 (64s)

Befehl:
w32tm /config /syncfromflags:manual /manualpeerlist:"0.at.pool.ntp.org 1.at.pool.ntp.org 2.at.pool.ntp.org "/update /reliable:yes
w32tm /resync

Time gschichtln hyper v:
http://blogs.msdn.com/b/robertvi/archive/2011/05/11/time-synchronization-and-domain-controller-vm-s.aspx

https://support.microsoft.com/en-us/kb/816042

https://technet.microsoft.com/en-us/library/virtual_active_directory_domain_controller_virtualization_hyperv(WS.10).aspx


Time Set Session:

C:\Users\Administrator>w32tm /query /status
Sprungindikator: 0(keine Warnung)
Stratum: 4 (Sekundärreferenz - synchr. über (S)NTP)
Präzision: -23 (119.209ns pro Tick)
Stammverzögerung: 0.0358491s
Stammabweichung: 0.0479295s
Referenz-ID: 0x3369D0AD (Quell-IP:  51.105.208.173)
Letzte erfolgr. Synchronisierungszeit: 14.05.2021 19:05:41
Quelle: time.windows.com,0x8
Abrufintervall: 10 (1024s)


C:\Users\Administrator>w32tm /config /manualpeerlist:"at.pool.ntp.org,0x8" /syncfromflags:manual /reliable:yes /update
Der Befehl wurde erfolgreich ausgeführt.

C:\Users\Administrator>net stop w32time && net start w32time
Windows-Zeitgeber wird beendet.
Windows-Zeitgeber wurde erfolgreich beendet.

Windows-Zeitgeber wird gestartet.
Windows-Zeitgeber wurde erfolgreich gestartet.


C:\Users\Administrator>w32tm /resync
Befehl zum erneuten Synchronisieren wird an den lokalen Computer gesendet.
Der Befehl wurde erfolgreich ausgeführt.

C:\Users\Administrator>w32tm /query /status
Sprungindikator: 0(keine Warnung)
Stratum: 3 (Sekundärreferenz - synchr. über (S)NTP)
Präzision: -23 (119.209ns pro Tick)
Stammverzögerung: 0.0123271s
Stammabweichung: 7.8446831s
Referenz-ID: 0x563B50AA (Quell-IP:  86.59.80.170)
Letzte erfolgr. Synchronisierungszeit: 14.05.2021 19:17:02
Quelle: at.pool.ntp.org
Abrufintervall: 6 (64s)


  • Keyserver auf clients bestimmen:
slmgr.vbs /ckms
slmgr.vbs /skms KMS_SERVER_ADRESSE
slmgr.vbs /ato
  • WSUS Illegaler Pfad Error:
It's not about root partition, it's about trailing slash. E:\WSUS\ will give you the same error. E:\WSUS will work.
kein "\" suffix
  • WSUS Laufzeitfehler - blabla unterschiedliche Laufzeitversionen (.NET schaß)
    • inetmgr ausführen
    • WSUS Pool auf .NET 4 umstellen von 2

Druckserver neu starten

@echo off
net stop spooler
del %SystemRoot%\spool\PRINTERS\*.tmp
net start spooler

Drucker per Cli hinzufügen

Examples:
Examples

To add a new remote printer, printer1, for a computer, Client1, which is visible for the user account where this command is run, type:

rundll32 printui.dll PrintUIEntry /in /n\\client1\printer1  

To add a printer using the add printer wizard and using an .inf file, InfFile.inf, located on drive c: at Infpath, type:

rundll32 printui.dll PrintUIEntry /ii /f c:\Infpath\InfFile.inf  

To delete an existing printer, printer1, on a computer, Client1, type:

rundll32 printui.dll PrintUIEntry /dn /n\\client1\printer1  

To add a per computer printer connection, printer2, for all users of a computer, Client2, type (the connection will be applied when a user logs on):

rundll32 printui.dll PrintUIEntry /ga /n\\client2\printer2  

To delete a per computer printer connection, printer2, for all users of a computer, Client2, type (the connection will be deleted when a user logs on):

rundll32 printui.dll PrintUIEntry /gd /n\\client2\printer2  

To view the properties of the print server, printServer1, type:

rundll32 printui.dll PrintUIEntry /s /t1 /c\\printserver1  

To view the properties of a printer, printer3, type:

rundll32 printui.dll PrintUIEntry /p /n\\printer3  

Druckerinstallation per Kommandozeile. Das Einrichten eines Netzwerkdrucker per CMD mit folgendem Befehl:

rundll32.exe printui.dll,PrintUIEntry /in /n “\\printsvr\KonicaMinolta 240f”

Der Parameter /in bedeutet > install network printer
Der Parameter /n gibt den Freigabenamen des Druckers an. In diesem Beispiel mit Pfadnamen zum Printserver.

Office 2013/Office 365

 To delete an Office profile that may still be cached

    From Registry Editor, browse to:

    HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\Identity\Identities

    Choose the Office profile that you want to delete, and then choose Delete.

    From the Identity hive, navigate to the Profiles node, choose that same identity, open the shortcut menu (right-click), and then choose Delete.
  • Office 2013 aktivieren:
@echo off

if not EXIST "C:\Program Files (x86)\Microsoft Office\Office15\" GOTO End

if EXIST "C:\activated.txt" GOTO End

cd "C:\Program Files (x86)\Microsoft Office\Office15\"

cscript ospp.vbs /act > C:\activated.txt


:End
  • Clutter überall deaktivieren:
1. Powershell administrative Berechtingungen
2. Set-ExecutionPolicy Unrestricted –force
3. $UserCredential = Get-Credential 
4. $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic –AllowRedirection
5. Import-PSSession $Session
6. Get-Mailbox -ResultSize Unlimited | Set-Clutter -Enable $False

Windows Aktivierungsstatus

So überprüfst Du, ob der KMS Server aktiviert

Slmgr.vbs /ckms
Slmgr.vbs /skms KMS_SERVER

Du kannst mit dem folgenden Befehl im Commandprompt überprüfen, ob die Aktivierung erfolgreich durchgeführt wird:
slmgr.vbs –ato
  • am DNS Server:
Using DNS Manager, in the appropriate forwarding lookup zone, create a new SRV RR using the appropriate information for the location. By default, KMS listens on TCP port 1688, and the service is _VLMCS. Table 2 contains example settings for a SRV RR.

Table 2   SRV Resource Record

Name
	

Setting

Service
	

_VLMCS

Protocol
	

_TCP

Port number
	

1688

Host offering the service
	

FQDN of KMS Host

Windows PE Boot Environment

  • Windows 7 : shift + F10 → Konsole
ipconfig /all -> ip check
drvload Pfad/*.inf -> Treiber laden

WSUS

# Variablen
$DateFormat = Get-Date -format yyyyMMdd-HH-mm
$Logfile = "D:\Logs\wsus-bereinigung-$DateFormat.log"
 
# WSUS Bereinigung durchführen
Invoke-WsusServerCleanup -CleanupObsoleteUpdates -CleanupUnneededContentFiles -CompressUpdates -DeclineExpiredUpdates -DeclineSupersededUpdates | Out-File $Logfile
 
  • Speicherort für die Updates verschieben (https://mntechblog.de/wsus-speicherort-updates-verschieben/)
  • zB: Nach F:\WSUS verschieben und Logfile erstellen
  • C:\Program Files\Update Services\Tools\WsusUtil.exe movecontent F:\WSUS F:\WSUS.log [-skipcontent]
  • Mit skipcontent ändert er offenbar nur die Config und versucht keinen Kopiervorgang
  • Achtung er schreibt es passt aber er ändert das VZ nicht !!!
  • Bei Erfolg und das alte Datenverzeichnis LÖSCHEN sonst ein lock!!
2018-08-27T08:23:57 Successfully stopped WsusService.
2018-08-27T08:23:57 Beginning content file location change to F:\WSUS\
2018-08-27T08:23:57 Did not copy files due to -skipcopy flag.
2018-08-27T08:23:57 Successfully changed WUS configuration.
2018-08-27T08:23:59 Successfully changed IIS virtual directory path.
2018-08-27T08:23:59 Successfully removed existing local content network shares.
2018-08-27T08:23:59 Successfully created local content network shares.
2018-08-27T08:23:59 Successfully changed registry value for content store directory.
2018-08-27T08:23:59 Successfully changed content file location.
2018-08-27T08:24:01 Successfully started WsusService.
2018-08-27T08:24:01 Content integrity check and repair...
2018-08-27T08:24:01 Initiated content integrity check and repair.

Office 365 Online World of Microsoft

Regelwerke für Nachrichten

  • Regelwerk um Nachrichten mit bestimmten Eigenschaften abzulehnen zB: DLP

Weiterleitung aktivieren

  • Falls es erforderlich wird „Weiterleitungen“ zu aktivieren - Achtung Microsoft hat hier gegen Ende November/Dezember 2020 die Policy geändert - dass per default keine Weiterleitungen mehr erlaubt sind
  • Bei Filterrichtlinie für ausgehendes Spam ‎(immer EIN)‎ - Richtlinie bearbeiten

Spam in Junk-Mail

  • Teilweise werden Mails von MS zum Frühstück verspeist und der Sender weiß nicht , dass die Mail nicht zugestellt wurde , wenn die Option Spam auf „Nachricht löschen“ steht - mit „Nachricht in Junk-E-Mail verschieben“ wird sie zumindest zum Empfänger zugestellt

Powershell - nice to know

  • Wird ein Powershell Skript aufgerufen , das mehrere Ausgaben enthält zB: mit write-host kann nicht einfach „redirected“ werden - sondern zB: mit Start-Transcript und Stop-Transcript kann die Ausgabe aufgezeichnet werden
PS C:\> Start-Transcript -path c:\docs\Text3.txt
        .\YOUR-SCRIPT.ps1
PS C:\> Stop-Transcript

Windows Server 2019

Domain Controller hinzufügen

  • Debugging mit dcdiag
  • Empfehlung Resolver „überkreuzen“ dc1 resolved zuerst über dc2 und dc2 zuerst über dc1
  • Zuerst Server installieren mit lokalem Benutzer - ins AD setzen und dann die Rolle hinzufügen
  • DHCP Server Konfiguration aktualisieren für weiteren DNS Server
  • Domäne: schule.intern Server dc2.schule.intern

MAK Key Fehler Aktivierung

Windows 10

Unattended XML File erstellen

  • Ziel war es ein unattended XML File zu erstellen , das die Festplatte partitioniert (UEFI) und eine Workgroup setzt - sonst soll alles Default sein damit der User das Windows 10 Professional Setup klicki feeling bekommt und in Eigenverantwortung die Fragen beantwortet
  • Es wurde eine Windows 10 Pro/Enterprise ISO genutzt die von den Microsoft VSLC Servern herunter geladen wurde
  • Das XML File kann sowohl am WDS Server für eine install.wim (zB: aus der ISO extrahiert und dem WDS Server hinzugefügt) als auch für eine USB Stick Installation verwendet werden - oder überhaupt per /unattend:XML_FILE definiert werden :)
  • XML am WDS Server (hier wurde bereits Windows 10 Pro ausgewählt beim install.wim Import) unattended-uefi.xml:
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="windowsPE">
        <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SetupUILanguage>
                <UILanguage>de-DE</UILanguage>
            </SetupUILanguage>
            <UserLocale>de-DE</UserLocale>
            <UILanguage>de-DE</UILanguage>
            <SystemLocale>de-DE</SystemLocale>
            <InputLocale>0407:00000407</InputLocale>
        </component>
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DiskConfiguration>
                <Disk wcm:action="add">
                    <CreatePartitions>
                        <CreatePartition wcm:action="add">
                            <Order>1</Order>
                            <Size>300</Size>
                            <Type>Primary</Type>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>2</Order>
                            <Size>100</Size>
                            <Type>EFI</Type>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>3</Order>
                            <Size>128</Size>
                            <Type>MSR</Type>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>4</Order>
                            <Type>Primary</Type>
                            <Extend>true</Extend>
                        </CreatePartition>
                    </CreatePartitions>
                    <ModifyPartitions>
                        <ModifyPartition wcm:action="add">
                            <Format>NTFS</Format>
                            <Label>WinRE</Label>
                            <Order>1</Order>
                            <PartitionID>1</PartitionID>
                            <TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID>
                        </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <Label>Windows</Label>
                            <Letter>C</Letter>
                            <Order>4</Order>
                            <PartitionID>4</PartitionID>
                            <Format>NTFS</Format>
                            </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <Order>3</Order>
                            <PartitionID>3</PartitionID>
                        </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <Order>2</Order>
                            <PartitionID>2</PartitionID>
                            <Format>FAT32</Format>
                            <Label>System</Label>
                        </ModifyPartition>
                    </ModifyPartitions>
                    <DiskID>0</DiskID>
                    <WillWipeDisk>true</WillWipeDisk>
                </Disk>
            </DiskConfiguration>
            <ImageInstall>
                <OSImage>
                    <InstallTo>
                        <DiskID>0</DiskID>
                        <PartitionID>4</PartitionID>
                    </InstallTo>
                    <WillShowUI>OnError</WillShowUI>
                    </OSImage>
            </ImageInstall>
            <UserData>
                <AcceptEula>true</AcceptEula>
            </UserData>
        </component>
    <settings pass="specialize">
        <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <Identification>
                <JoinWorkgroup>Private</JoinWorkgroup>
            </Identification>
        </component>
    </settings>
    </settings>
    <cpi:offlineImage cpi:source="wim:c:/tmp/install_1909.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
  • XML in Kombination mit iPXE - großes ISO Image unattended-uefi.xml:
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <settings pass="windowsPE">
        <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SetupUILanguage>
                <UILanguage>de-DE</UILanguage>
            </SetupUILanguage>
            <UserLocale>de-DE</UserLocale>
            <UILanguage>de-DE</UILanguage>
            <SystemLocale>de-DE</SystemLocale>
            <InputLocale>0407:00000407</InputLocale>
        </component>
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DiskConfiguration>
                <Disk wcm:action="add">
                    <CreatePartitions>
                        <CreatePartition wcm:action="add">
                            <Order>1</Order>
                            <Size>300</Size>
                            <Type>Primary</Type>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>2</Order>
                            <Size>100</Size>
                            <Type>EFI</Type>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>3</Order>
                            <Size>128</Size>
                            <Type>MSR</Type>
                        </CreatePartition>
                        <CreatePartition wcm:action="add">
                            <Order>4</Order>
                            <Type>Primary</Type>
                            <Extend>true</Extend>
                        </CreatePartition>
                    </CreatePartitions>
                    <ModifyPartitions>
                        <ModifyPartition wcm:action="add">
                            <Format>NTFS</Format>
                            <Label>WinRE</Label>
                            <Order>1</Order>
                            <PartitionID>1</PartitionID>
                            <TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID>
                        </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <Label>Windows</Label>
                            <Letter>C</Letter>
                            <Order>4</Order>
                            <PartitionID>4</PartitionID>
                            <Format>NTFS</Format>
                            </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <Order>3</Order>
                            <PartitionID>3</PartitionID>
                        </ModifyPartition>
                        <ModifyPartition wcm:action="add">
                            <Order>2</Order>
                            <PartitionID>2</PartitionID>
                            <Format>FAT32</Format>
                            <Label>System</Label>
                        </ModifyPartition>
                    </ModifyPartitions>
                    <DiskID>0</DiskID>
                    <WillWipeDisk>true</WillWipeDisk>
                </Disk>
            </DiskConfiguration>
            <ImageInstall>
                <OSImage>
                    <InstallTo>
                        <DiskID>0</DiskID>
                        <PartitionID>4</PartitionID>
                    </InstallTo>
                    <WillShowUI>OnError</WillShowUI>
                    <InstallFrom>
                        <MetaData wcm:action="add">
                            <Key>/IMAGE/NAME</Key>
                            <Value>Windows 10 Pro</Value>
                        </MetaData>
                    </InstallFrom>
                </OSImage>
            </ImageInstall>
            <UserData>
                <AcceptEula>true</AcceptEula>
            </UserData>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="wim:c:/tmp/install_1909.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

Aktivieren d. Keys aus BIOS

  • Sollte das Notebook zurück gesetzt worden sein und das Gerät mit dem Produktschlüssel ausgeliefert worden sein

MBR to UEFI

  • Konvertieren bestehender MBR basierender Systeme auf UEFI
  • Getestet mit Windows 10 LTSC 2019 (1809) - bestehendes System von MBR auf UEFI migrieren (Hyper-V Generation 1 → Generation 2 Maschine) / Gebootet wurde von LTSC 2021 Windows 10 ISO

MS-Intune Nice-to-Know Bug Features / powershell

  • FIXME - restart abbrechen mit shutdown -a / Azure integrierter Rechner / Nicht integrierter Rechner Unterschiede
  • Factory Reset mit → cmd (als Administrator) → systemreset
  • Infos zum Umgang mit MS Graph Intune Powershell / Installation
PS C:\Windows\system32> Install-Module -Name Microsoft.Graph.Intune

Der NuGet-Anbieter ist erforderlich, um den Vorgang fortzusetzen.
PowerShellGet erfordert die NuGet-Anbieterversion 2.8.5.201 oder höher für die Interaktion mit NuGet-basierten
Repositorys. Der NuGet-Anbieter muss in "C:\Program Files\PackageManagement\ProviderAssemblies" oder
"C:\Users\christian.CZECZIL\AppData\Local\PackageManagement\ProviderAssemblies" verfügbar sein. Sie können den
NuGet-Anbieter auch durch Ausführen von 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'
installieren. Möchten Sie den NuGet-Anbieter jetzt durch PowerShellGet installieren und importieren lassen?
[J] Ja  [N] Nein  [H] Anhalten  [?] Hilfe (Standard ist "J"): j

Nicht vertrauenswürdiges Repository
Sie installieren die Module aus einem nicht vertrauenswürdigen Repository. Wenn Sie diesem Repository vertrauen, ändern
 Sie dessen InstallationPolicy-Wert, indem Sie das Set-PSRepository-Cmdlet ausführen. Möchten Sie die Module von
'PSGallery' wirklich installieren?
[J] Ja  [A] Ja, alle  [N] Nein  [K] Nein, keine  [H] Anhalten  [?] Hilfe (Standard ist "N"): j
PS C:\Windows\system32> Get-Command -Module Microsoft.Graph.Intune
PS C:\Windows\system32> Install-Module -Name Microsoft.Graph.Intune
PS C:\Windows\system32> echo $?

-----


PS C:\Windows\system32> Set-ExecutionPolicy Bypass
PS C:\Windows\system32> Connect-MSGraph -AdminConsent

Get-IntuneManagedDevice

PS C:\Windows\system32> Get-Command -Module  Microsoft.Graph.Intune

CommandType     Name Version    Source
-----------     ---- -------    ------
Alias           Get-AADGroup 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupCreatedOnBehalfOf 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupCreatedOnBehalfOfReference 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupGroupLifecyclePolicy 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupMember 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupMemberOf 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupMemberOfReferenceSet 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupMemberReferenceSet 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupOwner 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupOwnerReferenceSet 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupPhoto 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupPhotoDataData 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupPhotoSet 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupPhotoSetDataData 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-AADGroupSetting 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppConfigurationPolicyTargeted 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppConfigurationPolicyTargetedApp 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppConfigurationPolicyTargetedAssignment 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppConfigurationPolicyTargetedDeploym... 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneApplePushNotificationCertificate 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppProtectionPolicy 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppProtectionPolicyAndroid 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppProtectionPolicyAndroidApp 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppProtectionPolicyAndroidAssignment 6.1907.1.0 Microsoft.Graph.Intune
Alias           Get-IntuneAppProtectionPolicyAndroidDeploymentS... 6.1907.1.0 Microsoft.Graph.Intune



-----


Discovering available commands

Get the full list of available cmdlets:

Get-Command -Module Microsoft.Graph.Intune

Get documentation on a particular cmdlet:

Get-Help <cmdlet name>

Use a UI to see the parameter sets more easily:

Show-Command <cmdlet name>
.... 

MS-Intune BYOD

  • BYOD Enrollment für MS Intune / Getestet auf Windows 10 LTSC 2019

Type Host name Points to TTL
CNAME 	EnterpriseEnrollment. company_domain.com 	EnterpriseEnrollment-s.manage.microsoft.com 	1 hour




The company_domain in the FQDN should be the registered domain name(s) you are using for single sign on with the UPN. For example if users at Contoso use name@contoso.com as their email/UPN, the Contoso DNS admin would need to create the following CNAMEs.


Type Host name Points to TTL
CNAME 	EnterpriseEnrollment. contoso.com 	EnterpriseEnrollment-s.manage.microsoft.com 	1 hour




If you have more than one UPN suffix, you need to create one CNAME for each domain name and point each one to EnterpriseEnrollment-s.manage.microsoft.com. For example if users at Contoso use name@contoso.com, but also use name@us.contoso.com, and name@eu.constoso.com as their email/UPN, the Contoso DNS admin would need to create the following CNAMEs.


Type Host name Points to TTL
CNAME 	EnterpriseEnrollment. contoso.com 	EnterpriseEnrollment-s.manage.microsoft.com 	1 hour
CNAME 	EnterpriseEnrollment. us.contoso.com 	EnterpriseEnrollment-s.manage.microsoft.com 	1 hour
CNAME 	EnterpriseEnrollment. eu.contoso.com 	EnterpriseEnrollment-s.manage.microsoft.com 	1 hour


Registration vs Enrollment CNAMEs


Azure Active Directory has a different CNAME that it uses for device registration for iOS, Android, and Windows devices. Intune conditional access requires devices to be registered, also called “workplace joined”. If you plan to use conditional access, you should also configure the EnterpriseRegistration CNAME for each company name you have.


Type Host name Points to TTL
CNAME 	EnterpriseRegistration. company_domain.com 	EnterpriseRegistration.windows.net 	1 hour

Remotehilfe

  • Getestet auf Windows 10 LTSC2019 / Windows 10 Pro 1909
  • Anforderung: Eine Windows built in Möglichkeit finden um Benutzern Remote Unterstützung geben zu können - Remotehilfe
  • Technische Infos:
Pfad:
%SystemRoot%\system32\quickassist.exe

Installation Powershell zB: auf LTSC 2019
Add-WindowsCapability -Online -Name "App.Support.QuickAssist~~~~0.0.1.0"


Traffic Firewall:
-funktioniert mit Proxy Server (getestet mit Ubuntu 18.04 / Squid)

-Einer der Einstiegspunkte zB: zum Blockieren - 
remoteassistance.support.services.microsoft.com Port 443
 
Kommunikation läuft grundsätzlich über TLS 1.2 siehe hiefür https://docs.microsoft.com/en-us/windows/client-management/quick-assist



-Laufende Kommunikation:
x.x.x.x - - [06/Apr/2021:14:06:54 +0200] "CONNECT webpooldm20r04.infra.lync.com:443 HTTP/1.0" 200 7690 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 52.112.81.29 - - x.x.x.x
x.x.x.x - - [06/Apr/2021:14:06:54 +0200] "CONNECT browser.pipe.aria.microsoft.com:443 HTTP/1.0" 200 6824 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 40.78.128.150 - - x.x.x.x
x.x.x.x - - [06/Apr/2021:14:06:54 +0200] "CONNECT web.vortex.data.microsoft.com:443 HTTP/1.0" 200 6873 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 40.77.226.250 - - x.x.x.x
x.x.x.x - - [06/Apr/2021:14:06:54 +0200] "CONNECT web.vortex.data.microsoft.com:443 HTTP/1.0" 200 6452 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 40.77.226.250 - - x.x.x.x
x.x.x.x - - [06/Apr/2021:14:06:57 +0200] "CONNECT webpooldm20r04.infra.lync.com:443 HTTP/1.0" 200 7706 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 52.112.81.29 - - x.x.x.x
x.x.x.x - - [06/Apr/2021:14:06:57 +0200] "CONNECT browser.pipe.aria.microsoft.com:443 HTTP/1.0" 200 7249 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 40.78.128.150 - - x.x.x.x
x.x.x.x - - [06/Apr/2021:14:06:57 +0200] "CONNECT webpooldm20r04.infra.lync.com:443 HTTP/1.0" 200 14541 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 52.112.81.29 - - x.x.x.x
x.x.x.x - - [06/Apr/2021:14:06:57 +0200] "CONNECT web.vortex.data.microsoft.com:443 HTTP/1.0" 200 8557 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 40.77.226.250 - - x.x.x.x
x.x.x.x - - [06/Apr/2021:14:06:57 +0200] "CONNECT web.vortex.data.microsoft.com:443 HTTP/1.0" 200 6031 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Win64; x64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" TCP_TUNNEL:HIER_DIRECT 40.77.226.250 - - x.x.x.x
  • Ablauf Sitzung
  • Programm auf beiden Maschinen starten d.h. derjenige der Support braucht (Support Nehmer) und derjenige der Support gibt (Support Geber)

  • Support Geber geht auf „Unterstützung gewähren“ und Support Nehmer braucht die ID des Support Gebers

  • Support geben d.h. unterstützung gewähren (erfordert Microsoft Account)

  • Support Geber erhält ID die dem Support Nehmer mitgeteilt werden muss

  • Support Nehmer trägt ID des Gebers ein

  • Support Geber wählt ob er Vollzugriff oder nur Bildschirm anzeigen möchte (eigentlich sollte dies der Support Nehmer bestimmen .. :))

  • Support Nehmer muss Zugriff erlauben

  • Sitzung wird aufgebaut

  • Grundsätzlich können GPO's definiert werden ob auf Maschinen zugegriffen werden darf oder nicht / Funktioniert bei LTSC 2019 offenbar nicht, Einstellung wird vom System ignoriert FIXME

Administrator Account Hinzufügen / Resetten / Aktivieren

  • Booten von externem Datenträger zB: Windows live DVD/ USB Stick / shift + F10 für command prompt
  • utilman.exe durch cmd.exe austauschen im system32 vom Produktiv - System
  • Wenn das System noch bootet Links neben Power Icon drücken → Command Prompt öffnet sich mit Admin Berechtigungen
  • Administrator Account aktivieren und Passwort zurück setzen:
net user Administrator Administrator /active:yes  /expires:never

Lokale Benutzer Startup

  • Pfad für lokale Startup Skripten: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
  • Ablage von zB: bat Files möglich

Upgrade LTSB 2016 to LTSC2019

  • Geht über LTSC2019 ISO obwohl offiziell nicht supported - über reguläres Setup Programm
  • Nach Upgrade ist sysprep nicht mehr möglich (Microsoft.Windows.SecondaryTileExperience_10.0.0.0_netral_cw5n1h2txyewy) Offenbar verweist das System auf diese App die jedoch bereits gelöscht wurde durch das Upgrade (Errors: 0x3cf2 , 0x80073cf2)
  • sysprep hat wieder funktioniert nach folgenden Schritten FIXME
1. Systemplatte räumen lassen / inklusive Systemdateien
2. Benutzerprofile löschen über Win GUI , die sich löschen lassen /
 Erweiterte Einstellungen / Benutzerprofile
3. Installation kb4476976
https://support.microsoft.com/en-us/topic/january-22-2019-kb4476976-os-build-17763-292-21eea485-af3a-2d1e-e3e5-f48ba53def26 (?)
4. Rechner aus dem AD nehmen / wieder Workstation wie bei Erstmaligem sysprep
5. AppXDB Editor für Pakete - https://github.com/SoftSonic83/AppxDBEditor
Microsoft.Windows.SecondaryTileExperience=0
Windows.MiracastView=0
Microsoft.LanguageExperiencePackde-DE=0

6. AppxDBEditor cmd -> so lange bis keine Fehlermeldung kommt / Status ändern auf "löschbar"


7. Admin Powershell 
Get-AppxPackage -AllUser -Name Microsoft.Windows.SecondaryTileExperience | Remove-AppxPackage -AllUsers
Get-AppxPackage -AllUser -Name  Windows.MiracastView | Remove-AppxPackage -AllUsers
Get-AppxPackage -AllUser -Name  Microsoft.LanguageExperiencePackde-DE | Remove-AppxPackage -AllUsers


8. Reboot

9. Sysprep hakerl setzen / oobe Experience / herunterfahren

Upgrade Windows 7 to Windows 10

  • Mit Windows Update Assistent
  • Sollte bei „Updates suchen“ bei 46% stecken bleiben folgende Schritte durchführen - Stop vom Windows Update Dienst - er startet ihn ndanach wieder automatisch
Administrator CMD.exe ->
 net stop wuauserv to stop

Windows - Telemetrie für die Firewall zum blocken

  • Achtung aggregierte Portale die zB: bei akamai liegen bei ipset blocks
vortex.data.microsoft.com
vortex-win.data.microsoft.com
telecommand.telemetry.microsoft.com
telecommand.telemetry.microsoft.com.nsatc.net
oca.telemetry.microsoft.com
oca.telemetry.microsoft.com.nsatc.net
sqm.telemetry.microsoft.com
sqm.telemetry.microsoft.com.nsatc.net
watson.telemetry.microsoft.com
watson.telemetry.microsoft.com.nsatc.net
redir.metaservices.microsoft.com
choice.microsoft.com
choice.microsoft.com.nsatc.net
df.telemetry.microsoft.com
reports.wes.df.telemetry.microsoft.com
wes.df.telemetry.microsoft.com
services.wes.df.telemetry.microsoft.com
sqm.df.telemetry.microsoft.com
telemetry.microsoft.com
watson.ppe.telemetry.microsoft.com
telemetry.appex.bing.net
telemetry.urs.microsoft.com
telemetry.appex.bing.net
settings-sandbox.data.microsoft.com
vortex-sandbox.data.microsoft.com
survey.watson.microsoft.com
watson.live.com
watson.microsoft.com
statsfe2.ws.microsoft.com
corpext.msitadfs.glbdns2.microsoft.com
compatexchange.cloudapp.net
cs1.wpc.v0cdn.net
a-0001.a-msedge.net
statsfe2.update.microsoft.com.akadns.net
sls.update.microsoft.com.akadns.net
fe2.update.microsoft.com.akadns.net
diagnostics.support.microsoft.com
corp.sts.microsoft.com
statsfe1.ws.microsoft.com
pre.footprintpredict.com
i1.services.social.microsoft.com
i1.services.social.microsoft.com.nsatc.net
feedback.windows.com
feedback.microsoft-hohm.com
feedback.search.microsoft.com
adnexus.net
adnxs.com
az361816.vo.msecnd.net
az512334.vo.msecnd.net
vortex-bn2.metron.live.com.nsatc.net
vortex-cy2.metron.live.com.nsatc.net
dmd.metaservices.microsoft.com

Systemsteuerung direkt ausführen als -> ms-setting

https://www.deskmodder.de/blog/2015/06/03/windows-10-einstellungen-direkt-aufrufen-ausfuehren-dialog/

Einstellungsseite 	Befehl
Startseite 	ms-settings:
Energiesparmodus 	ms-settings:batterysaver
Energiesparmodus (Einstellungen) 	ms-settings:batterysaver-settings
Akkuverbrauch (Nutzung) 	ms-settings:batterysaver-usagedetails
Bluetooth-Geräte verwalten 	ms-settings:bluetooth
Farben 	ms-settings:colors
Datennutzung 	ms-settings:datausage
Datum und Zeit 	ms-settings:dateandtime
Untertitel für Hörgeschädigte 	ms-settings:easeofaccess-closedcaptioning
Hoher Kontrast 	ms-settings:easeofaccess-highcontrast
Bildschirmlupe 	ms-settings:easeofaccess-magnifier
Sprachausgabe 	ms-settings:easeofaccess-narrator
Tastatur 	ms-settings:easeofaccess-keyboard
Maus 	ms-settings:easeofaccess-mouse
Erleichterte Bedienung (Weitere Optionen) 	ms-settings:easeofaccess-otheroptions
Sperrbildschirm 	ms-settings:lockscreen
Offline Navigation (Karten) 	ms-settings:maps
Flugzeugmodus 	ms-settings:network-airplanemode
Proxy 	ms-settings:network-proxy
VPN 	ms-settings:network-vpn
Benachrichtigungen und Aktionen 	ms-settings:notifications
Konto-Information 	ms-settings:privacy-accountinfo
Kalender 	ms-settings:privacy-calendar
Kontakte 	ms-settings:privacy-contacts
Weitere Geräte 	ms-settings:privacy-customdevices
Feedback 	ms-settings:privacy-feedback
Position (Ortung) 	ms-settings:privacy-location
Nachrichten 	ms-settings:privacy-messaging
Mikrofon 	ms-settings:privacy-microphone
Bewegungsdaten 	ms-settings:privacy-motion
Funkempfang 	ms-settings:privacy-radios
Spracherkennung, Freihand, Eingabe (Cortana) 	ms-settings:privacy-speechtyping
Kamera 	ms-settings:privacy-webcam
Region und Sprache 	ms-settings:regionlanguage
Sprache (Ein- und Ausgabe) 	ms-settings:speech
Windows Update 	ms-settings:windowsupdate
Arbeitsplatzzugriff 	ms-settings:workplace
Angeschlossene Geräte 	ms-settings:connecteddevices
Für Entwickler 	ms-settings:developers
Bildschirm 	ms-settings:display
Maus und Touchpad 	ms-settings:mousetouchpad
Mobilfunk 	ms-settings:network-cellular
Einwahlverbindung (DFÜ) 	ms-settings:network-dialup
DirectAccess 	ms-settings:network-directaccess
Ethernet 	ms-settings:network-ethernet
mobiler Hotspot 	ms-settings:network-mobilehotspot
Wi-Fi 	ms-settings:network-wifi
Wi-Fi (Einstellungen) 	ms-settings:network-wifisettings
Optionale Funktionen 	ms-settings:optionalfeatures
Familie und weitere Benutzer 	ms-settings:otherusers
Personalisierung 	ms-settings:personalization
Hintergrund 	ms-settings:personalization-background
Farben 	ms-settings:personalization-colors
Start 	ms-settings:personalization-start
Netzbetrieb und Energiesparen 	ms-settings:powersleep
Annäherungssensor 	ms-settings:proximity
Display-Rotation 	ms-settings:screenrotation
Anmeldeoptionen 	ms-settings:signinoptions
Speicher (Verbrauch) 	ms-settings:storagesense
Themes 	ms-settings:themes
Eingabe (Rechtschreibung) 	ms-settings:typing
Tablet-Modus 	ms-settings:tabletmode
Datenschutzoptionen 	ms-settings:privacy

Windows RAM Belegung auslesen

f you don't mind using the command line, WMI can do this and is native with Windows XP and newer.

Simply run wmic MEMORYCHIP get BankLabel,DeviceLocator,Capacity,Tag

>wmic MEMORYCHIP get BankLabel,DeviceLocator,Capacity,Tag
BankLabel  Capacity    DeviceLocator            Tag
BANK 0     2147483648  Bottom - Slot 1 (top)    Physical Memory 0
BANK 1     4294967296  Bottom - Slot 2 (under)  Physical Memory 1

(DeviceLocator will likely give you DIMM numbers on a desktop machine - the top/under slots are because I'm on a laptop. Both BankLabel and DeviceLocator formats may vary by machine.)

Startmenü anpassen

Step 1: Design your start menu

Remove / add tiles and apps to and from your start menu ready for the layout to be exported
Step 2: Run Windows PowerShell as administrator

Run the PowerShell as administrator and run the command:

Export-StartLayout –path <path><file name>.xml

Should look like this:

export-startlayout -path C:\startlayout.xml
Step 3: Open Group policy management console (gpmc.msc) and create new GPO

Create a new GPO

Go to User Configuration or Computer Configuration > Policies > Administrative Templates >Start Menu and Taskbar

Right-click Start Layout in the right pane, and click Edit. This opens the Start Layout policy settings

(Please note you will need the Windows 10 GPO add in downloaded to do this, I have a How-to on my page on how to get them, or Windows server 2016.)

Link:
https://community.spiceworks.com/how_to/139795-add-windows-10-group-policy-objects-to-windows-server-2012-r2
Step 4: Configure the GPO

Enter the following settings, and then click OK:

Select Enabled

Under Options, specify the path to the .xml file that contains the Start layout. For example, type C:\Users\Test01\StartScreen.xml or \\ShareName\StartScreen.xml.

Optionally, enter a comment to identify the Start layout.
Step 5: Roll out the GPO

Open CMD on the server and type:

gpupdate /force

And get everyone to restart their work stations

AppAssoc exportieren - Achtung Fehler 0x80004002

Microsoft Windows [Version 10.0.16299.309]
(c) 2017 Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\Administrator.RESERVE-PC01>cd Desktop

C:\Users\Administrator.RESERVE-PC01\Desktop>dism /online /Export-DefaultAppAssociations:assoc-adobe.xml

Tool zur Imageverwaltung für die Bereitstellung
Version: 10.0.16299.15

Abbildversion: 10.0.16299.309


Fehler: 0x80004002

Die aktuellen Benutzerzuordnungen konnten nicht in die Datei "assoc-adobe.xml" exportiert werden.
Weitere Informationen finden Sie in der Hilfe.

Die DISM-Protokolldatei befindet sich unter "C:\Windows\Logs\DISM\dism.log".

C:\Users\Administrator.RESERVE-PC01\Desktop>


What the fuck :(
https://social.technet.microsoft.com/Forums/en-US/5161bd23-733e-4e2f-a500-d652fc23b81d/the-current-user-associations-could-not-be-exported-to-file-error-0x80004002?forum=win10itprosetup

wusa /uninstall /kb:4088776

what the fuck ² deinstall takes >45 minutes..
----

dism /online /Export-DefaultAppAssociations:assoc-adobe.xml

---


C:\Users\Administrator.RESERVE-PC01\Desktop>cd C:\TMP

C:\TMP>dism /online /Export-DefaultAppAssociations:assoc-adobe.xml

Tool zur Imageverwaltung für die Bereitstellung
Version: 10.0.16299.15

Abbildversion: 10.0.16299.125

Der Vorgang wurde erfolgreich beendet.

batch driver installation

Speaking of newer versions of Windows. In Hyper-V Server 2012 r1 & r2, the command-line is: pnputil  <driverinf> – Granger Sep 29 '16 at 3:48

batch subdirectory search and delete


for /d /r "c:\" %%a in (temp\) do if exist "%%a" echo rmdir /s /q "%%a"

For each folder (/d), recursively (/r) under c:\ test for the presence of a temp folder and if it exist, remove it

directory removal command is only echoed to console. If the output is correct, remove the echo command

DISM foo

  • dism magic (image mounted: -Image:D:\Mount)
DISM /Online /Cleanup-Image /CheckHealth

wol geht net

  • wol geht nixda mehr / Gerätemanager wurscht / Hybrid Boot ist deaktiviert! Bios Remote Server HP 800 G1 64Bit Windows 10 16xx
  • Original Intel 64Bit Windows Treiber von der Intel Seite runterladen!! Da muss ein Bug im Microsoft Treiber sein

Default Programme spezifizieren

Dism /Online /Export-DefaultAppAssociations:\\Server\Share\AppAssoc.xml

Windows 7

urbackup restore/windows bare metal restore - boot auf IDE setzen

  • Sollte bei Windows 7/XP nach einem Hardwareumzug oder Restore von AHCI auf IDE umgestellt worden sein und der entsprechende Bluescreen mit Auto Reboot erscheinen
  • Dieser Fall tritt ein wenn zB: der Restore auf einem Hyper-V (getestet Windows 2016 Hyper-V) durchgeführt wird d.h. die Hardware ausgetauscht
  • Hirens Boot CD (Achtung legacy Version einsetzen https://www.hirensbootcd.org/files/Hirens.BootCD.15.2.zip)
  • Tool: fix_hdc.cmd ↔ editiert die Registry entsprechend - leider gibt es einen Bug der es nicht zulässt Hirens Boot CD auf Hyper-V zu starten (er bleibt nach der Auswahl des Mini XP hängen)

psexec Batch command ausführen - netzwerkdrucker löschen

for /F %%f in (DV2.txt.txt) do (
 psexec \\%%f -u Administrator -p PASSWORD C:\Windows\System32\cmd.exe /C rundll32 printui.dll,PrintUIEntry /dn /n \\schulserver\EDV2
)
pause

Sprachsteuerung

Du klickst auf Start -> Systemsteuerung -> Center für erleichterte
Bedienung -> Computer ohne einen Bildschirm verwenden.

Dort kannst du die Hakerl rausnehmen wie im Bild angeführt und OK
klicken damit er die Einstellungen übernimmt.

Display klonen über cmd

Displayswitch.exe also has command line parameters that allow you to create a shortcut that will set a specific display mode. /internal /clone /extend /external – JJS Jun 15 '12 at 22:41 

Windows Gruppenrichtlinien

  • Achtung Bei Proxy Einstellungen F5/F6 zum Aktivieren drücken IE 10 Win2012r2 !!

Drucker

HP2055dn

  • Wenn er gleich nach dem Starten einen Hex Error anzeigt mit Boot foo → Firmware beschädigt
  • Drucker via USB an Endgerät ↔ PLC6 Treiber installieren lokal ↔ Tool aus ZIP öffnen HP Firmware rescue
  • Beim Starten von Drucker abbrechen u. Ok gleichzeitig ←→ bootcode Anzeige auf Display ←→ Tool von HP
  • Rescue Firmware: hp2055-boot-rescue.zip

Windows PXE Server + Linux Bootserver mit NFS

  • Infomaterialien bezüglich PXE Boot mit syslinux über einen WDS Deployment Server (2012r2) + NFS Bootserver
  • Exports am NFS Server e.g:
#PXE boots
/srv/grml96 10.0.0.0/8(ro,sync,insecure,no_subtree_check) 192.168.0.0/16(ro,sync,insecure,no_root_squash,no_subtree_check)
/srv/mint18 10.0.0.0/8(ro,sync,insecure,no_root_squash,no_subtree_check) 192.168.0.0/16(ro,sync,insecure,no_root_squash,no_subtree_check)
/srv/avira 10.0.0.0/8(ro,sync,insecure,no_root_squash,no_subtree_check) 192.168.0.0/16(ro,sync,insecure,no_root_squash,no_subtree_check)
/srv/wipe 10.0.0.0/8(ro,sync,insecure,no_root_squash,no_subtree_check) 192.168.0.0/16(ro,sync,insecure,no_root_squash,no_subtree_check)

Keywords: WDS , Deployment, PXE , PXE-Boot, boot, Network Boot, wds , deployment , pxe 

dhcp-server pxe bios boot optionen

  • bei dnsmasq:
dhcp-boot=pxelinux.0,HOSTNAME_SERVER,IP_SERVER

Applikationen/GPOs

Profile automatisiert löschen bei Speichermangel

$driveCheck="C"
$threshold=10


#2022-03-10 cc: Thanks https://stackoverflow.com/questions/12159341/how-to-get-disk-capacity-and-free-space-of-remote-computer
$foo=Get-PSDrive C 
$foo=$($foo.Free)

$message = ""


if( ($foo/ 1GB) -lt $threshold ) 
{
$message = "Disk Space is NOT good - Drive: "+$driveCheck+" / GB free: "+($foo/1GB)+" / Computer: "+$env:computername+" / Threshold GB: "+$threshold+"`r`n"

$message += . '\\DOMAIN\SysVol\DOMAIN\Policies\POL_ID\Machine\Scripts\Startup\delprof2.exe' /u

}
else
{
$message = "Disk Space is good - Drive: "+$driveCheck+" / GB free: "+($foo/1GB)+" / Computer: "+$env:computername+" / Threshold GB: "+$threshold
}



write-Output ($message) > C:\harddisk_check.txt

Shutdown if 2.5 hours idle

  • Computer GPO → Starten
  • Offensichtlich existiert ein Bug im Windows 10 (Getestet auf LTSB 2016) , der dazu führt dass der „Computer Idle“ Trigger aber erst nach x Stunden nicht funktioniert - nach ~10 Minuten wird das Programm ausgeführt egal wie die Idle Wait Werte gesetzt sind
  • Workaround nach 10 Minuten wird shutdown.bat gestartet die 9000 Sekunden darauf wartet ein Shutdown durchzuführen / Wird innerhalb von 9000 Sekunden der Rechner aus dem IDLE State unterbrochen wird die Batch Datei beendet
  • deploy_shutdown_trigger.bat
if exist "C:\trigger_shutdownifidle_success.txt" goto ENDE

if exist "C:\Scripts" goto Copy_BAT

mkdir C:\Scripts

icacls C:\Scripts /grant Administratoren:F /grant SYSTEM:F /grant Administrator@schule.intern:F /inheritance:r

:Copy_BAT

icacls C:\Scripts /grant Administratoren:(CI)(OI)(F) /grant SYSTEM:(CI)(OI)(F) /grant Administrator@schule.intern:(CI)(OI)(F) /inheritance:r

copy /Y \\DOMAIN\SysVol\DOMAIN\Policies\PATH_POLICY\Machine\Scripts\Startup\shutdown.bat C:\Scripts\shutdown.bat

schtasks /create /xml "\\DOMAIN\SysVol\DOMAIN\Policies\PATH_POLICY\Machine\Scripts\Startup\\ShutdownIdle.xml" /tn "Trigger_Shutdown_If_Idle" 

if %ERRORLEVEL% EQU 0 ( echo "success" > C:\trigger_shutdownifidle_success.txt )

:ENDE
  • ShutdownIdle.xml
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2020-11-12T10:57:39.9973789</Date>
    <Author>SCHULE\christian.czeczil</Author>
    <URI>\Trigger_Shutdown_If_Idle</URI>
  </RegistrationInfo>
  <Triggers>
    <IdleTrigger>
      <Enabled>true</Enabled>
    </IdleTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>false</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <Duration>PT10M</Duration>
      <WaitTimeout>PT0S</WaitTimeout>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>true</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\Scripts\shutdown.bat</Command>
    </Exec>
  </Actions>
</Task>
  • shutdown.bat
timeout 9000 /nobreak
shutdown /a
shutdown /f /s /t 0
  • enable_shutdown_if_idle.bat
if not exist C:\trigger_shutdownifidle_success.txt goto Ende

schtasks /change /ENABLE /tn "Trigger_Shutdown_If_Idle" > C:\trigger_Shutdown_If_Idle_ENABLE.txt 2>&1


:Ende
  • disable_shutdown_if_idle.bat
if not exist C:\trigger_shutdownifidle_success.txt goto Ende

schtasks /change /DISABLE /tn "Trigger_Shutdown_If_Idle" > C:\trigger_Shutdown_If_Idle_DISABLE.txt 2>&1


:Ende

Office 2019 Professinal Plus - MAK Key Installation

  • Das ODT - lädt eine setup.exe herunter die Click-to-Run Version von Office
  • Vor dem Einsatz der Batch Datei Programmdateien herunter laden mit setup.exe /download setup.xml
  • Bei PIDKEY kann gleich der MAK Key eingetragen werden für die Installation
  • Ich möchte in dieser Variante die Installation bzw. Deinstallation manuell anstoßen können umd die betroffenen User sollen den Forstschritt sehen können („Full“)
  • setup.xml
<!-- Office 2019 enterprise client configuration file sample. To be used for Office 2019 
     enterprise volume licensed products only, including Office 2019 Professional Plus,
     Visio 2019, and Project 2019.

     Do not use this sample to install Office 365 products.

     For detailed information regarding configuration options visit: http://aka.ms/ODT. 
     To use the configuration file be sure to remove the comments

     The following sample allows you to download and install Office 2019 Professional Plus,
     Visio 2019 Professional, and Project 2019 Professional directly from the Office CDN.

 -->



<Configuration>

  <Add OfficeClientEdition="32" Channel="PerpetualVL2019">
    <Product ID="ProPlus2019Volume" PIDKEY="">
      <Language ID="de-de" />
    </Product>
  </Add>

  <!--  <RemoveMSI All="True" /> -->

   <Display Level="Full" AcceptEULA="TRUE" />  

   <Property Name="AUTOACTIVATE" Value="1" />  
</Configuration>
  • uninstall_office.xml
<Configuration Product="ProPlus"> 
<Display Level="Full" CompletionNotice="no" SuppressModal="yes" AcceptEula="yes" /> 
</Configuration>
  • Deinstalliert ein vorhandene Office 2016 MAK Installation die noch per ISO installiert wurde
  • Install_Office_2019.bat
if exist "C:\Program Files (x86)\Microsoft Office\root\Office16" goto Ende
if exist "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE16\Office Setup Controller\setup.exe" goto Remove

goto Install


:Remove
"C:\Program Files (x86)\Common Files\microsoft shared\OFFICE16\Office Setup Controller\setup.exe" /uninstall ProPlus /config \\schulserver\windows10-programme$\Office2019\uninstall_office.xml

:Wait
timeout 10 /nobreak
if exist "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE16\Office Setup Controller\setup.exe" goto Wait


:Install
\\schulserver\windows10-programme$\Office2019\setup.exe /configure \\schulserver\windows10-programme$\Office2019\setup.xml

echo "installed_office2019" > C:\Office2019_installed.txt


:Ende

echo finished

pause

Windows Auto Login deaktivieren

Windows Auto Login aktivieren für Benutzer

  • Kann sich auch um AD Benutzer handeln / Computer Richtlinie Startup
  • ACHTUNG GPOS für Computer sind für alle authentifizierten Benutzer im AD lesbar

Windows Upgrade LTSB2016 auf LTSC (2019)

  • hat als Computerrichtlinie nicht geklappt :(
  • Achtung als Benutzerrichtlinie startup d.h. es wird ein Benutzer mit lokalen Administratorrechten gebraucht ggf. diverse Reboots
  • In Kombination mit Auto Login für Upgrade User mit lokalen Administrator Rechten / Falls bereits auf LTSC 2019 aktualisiert wurde wird wieder ausgeloggt
echo off


FOR /F "tokens=4 USEBACKQ" %%F IN (`ver`) DO (
SET var=%%F
)

#Windows 10 LTSC (2019)
if %var% == 10.0.17763.107] goto Ausloggen

\\schulserver\windows10-programme$\LTSC2019\setup.exe /auto upgrade /dynamicupdate disable  /compat ignorewarning


:Ende

exit

:Ausloggen

logoff

exit

Windows Updates deaktivieren

  • Getestet auf Windows 10 2016 LTSB
echo > C:\disable_updates.txt
sc config wuauserv start= disabled > C:\disable_updates.txt 2>&1
sc config usosvc start= disabled >> C:\disable_updates.txt 2>&1
net stop wuauserv >> C:\disable_updates.txt 2>&1
net stop usosvc >> C:\disable_updates.txt 2>&1

Windows Updates aktivieren

  • Getestet auf Windows 10 2016 LTSB
echo > C:\enable_updates.txt

sc config wuauserv start= demand > C:\enable_updates.txt 2>&1
sc config usosvc start= demand >> C:\enable_updates.txt 2>&1
net start wuauserv >> C:\enable_updates.txt 2>&1
net start usosvc >> C:\enable_updates.txt 2>&1

Windows Updates durchführen

  • Getestet auf Windows 10 2016 LTSB / LTSC 2019
  • Funktioniert nicht mehr mit LTSC 2021
%SystemRoot%\system32\usoclient.exe ScanInstallWait

%SystemRoot%\system32\timeout.exe /T 300 /NOBREAK

%SystemRoot%\system32\usoclient.exe StartInstall


echo > C:\update_durchfueren.txt

Windows Updates manuell planen u. installieren

  • Getestet mit LTSC 2019
  • Nachdem der Update Plan (Stand 18.05.2022) ignoriert wird und keine Updates mehr entsprechend der Gruppenrichtlinien installiert werden muss wieder eine manuelle Lösung her
  • Die Microsoft native Art und Weise die Updates über powershell zu installieren funktioniert nicht wird einmal entfernt oder wieder hinzugefügt
  • Achtung bei LTSC 2016 verwendet die Maschine per Default NICHT TLS1.2 - FAIL
  • Achtung ggf. Asynchron ausführen (Computerrichtlinien→ System → Skripts) und NICHT auf Netzwerk warten
  • Danke an den Entwickler von PSWindowsUpdate / GPO Rechner Start / Powershell Modul auf Rechnern installiereninstall_ps_windowsupdate.ps1

if ( -not ( Get-Module -ListAvailable -Name PSWindowsUpdate ) )
{
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force > C:\install_ps_windowsupdate_log.txt
Install-Module -Name PSWindowsUpdate -Force  >> C:\install_ps_windowsupdate_log.txt


}
else
{
write-host "PSWindows Update already installed"
}
  • Updates an einem bestimmten Tag zu einer bestimmten Uhrzeit installieren - am Mittwoch vor 07:00 (Rechner werden zB: um 06:50 geweckt) / GPO Rechner Start install_on_day_updates.ps1
#%A 	Day of the week - full name 	Monday
#%u 	Numeric day of the week (1-7) 	Monday = 1, Sunday = 7


$current_day=(Get-Date -UFormat "%u").toString()
$current_hour=(Get-Date -UFormat "%H")

#write-host $current_day


if ($current_day -eq "3" -and ([int]$current_hour -lt 7))
{


if(Get-Module -ListAvailable -Name PSWindowsUpdate)
{
 Get-WindowsUpdate  > C:\Windows_update.txt
Install-WindowsUpdate -MicrosoftUpdate -IgnoreReboot -AcceptAll >> C:\windows_update.txt

}





}

Microsoft Teams Installation

if exist C:\teams_installed.txt goto Ende

msiexec /i \\SERVER_PATH_TRUSTED\Teams_windows_x64.msi OPTIONS="noAutoStart=true" ALLUSERS=1

echo foo > C:\teams_installed.txt

:Ende

Microsoft Teams Upgrade Installation

  • Da die Version in X tagen nicht mehr verwendbar ist
  • Neue MSI Datei saugen → alte MSI Datei behalten und umbenennen
if exist C:\teams_installed_1.txt goto Ende
if exist C:\teams_installed.txt goto Deinstallieren
if not exist C:\teams_installed.txt goto Installieren

:Deinstallieren
msiexec /x  \\SERVER_PATH_TRUSTED\Teams_windows_x64_old.msi /quiet

:Installieren
msiexec /i \\SERVER_PATH_TRUSTED\Teams_windows_x64.msi OPTIONS="noAutoStart=true" ALLUSERS=1



echo foo > C:\teams_installed_1.txt

:Ende

Immunet silent Deinstallation

  • ImmunetSetup.exe muss noch vorhanden sein ggf. runterladen
  • delete_immunet.bat
if exist "C:\immunet_deinstalled.txt" goto ENDE

\\share_network\ImmunetSetup.exe /S /remove 1

echo "deinstalled" > C:\immunet_deinstalled.txt" 

:ENDE

Archicad Education 24 verteilen

  • Version 19 deinstallieren - Achtung Reboot direkt nach Deinstallation - Archicad24 daraufhin installieren
if exist "C:\Program Files\GRAPHISOFT\ArchiCAD 19\ArchiCAD.exe" goto Uninstall19
if exist "C:\archicad24_installed.txt" goto Ende

"\\share_network\ArchiCad24\ARCHICAD-24-AUT-3008-1.7.exe" --mode unattended --enableautomaticupdate 0 --eduSerialNumber SERIAL_NUMBER --eduUserID USER_ID


echo > C:\archicad24_installed.txt

goto Ende

:Uninstall19

start "" /wait  "C:\Program Files\GRAPHISOFT\ArchiCAD 19\Uninstall.AC\uninstaller.exe" -silent

shutdown /r /t 60

:Ende

PrinterNightmare nightmare

$printerName="HP-DRUCKER-DIREKT"
$printerIP="IP-HP-DRUCKER"
$printerCheck="C:\HP-DRUCKER-DIREKT-installed.txt"


if ( -not (Test-Path "C:\HP-Printer-Drivers-installed.txt") )
{
#Standort PCL6 Treiber von HP
pnputil /add-driver \\SERVER\FREIGABE\*.inf /install /subdirs > C:\HP-Printer-Drivers-installed.txt

}

if ( -not (Test-Path $printerCheck ))
{
Add-PrinterDriver -Name "HP Universal Printing PCL 6"
Add-PrinterPort -Name $printerIP"_Port_Manual" -PrinterHostAddress $printerIP
Add-Printer -Name $printerName -PortName $printerIP"_Port_Manual" "HP Universal Printing PCL 6"

if($?)
{
write-host "installed" > $printerCheck

}
}

Hardware Details erfassen

  • Um wesentliche Hardwaredetails der Rechner zu erfassen wie Hersteller des Geräts / Seriennummern / Prozessor / RAM / Festplatte - mit Get-WmiObject -List erhält man eine Liste mit allen Möglichkeiten
  • Als Startup - Computer Richtlinie geeignet , am Share ausschließlich Schreib-Zugriff auf „Domänencomputer“ geben
  • hardwareDetails.ps1
#Get-WmiObject -List

$checkFile="\\SERVER\HWDETAILS$\$env:computername.log"

if ( -not (Test-Path $checkFile))
{

Get-WmiObject -Class Win32_Bios | Format-List -Property * | Out-File $checkFile

Get-WmiObject -Class Win32_Processor | Format-List -Property * | Out-File -Append $checkFile

Get-WmiObject -Class Win32_DiskDrive | Format-List -Property * | Out-File -Append $checkFile

Get-WmiObject -Class Win32_PhysicalMemory | Format-List -Property * | Out-File -Append $checkFile

}

Archicad Education Lizenz verteilen

  • Sollte Lizenz abgelaufen sein auf Referenzmaschine erneuern u. education.lic verteilen auf andere Maschinen
  • deploay_archicad_license.bat
@echo off

if exist "C:\archicad_license_2019.txt" goto Ende


copy /Y \\share_network\education.lic "C:\Program Files\GRAPHISOFT\ArchiCAD 19"

if %errorlevel% equ 0 ( echo "success" > C:\archicad_license_2019.txt )

:Ende

Google Sketchup 8 deinstallieren

  • Falls Installations .msi Datei noch vorhanden
if exist C:\sketchup8_deinstalled.txt goto Ende

msiexec.exe /x "\\LOCATION\Sketchup_8\GoogleSketchUp8.msi" /q

echo > C:\sketchup8_deinstalled.txt

:Ende

MSDT Diagnose deaktivieren

  • disable_msdt.bat
if exist C:\ms-msdt.reg goto Ende

reg export HKEY_CLASSES_ROOT\ms-msdt C:\ms-msdt.reg

reg delete HKEY_CLASSES_ROOT\ms-msdt /f 

:Ende
  • Update Es ist ebenfalls möglich auf einer lokalen Maschine die msdt.exe im System32\ Ordner umzubenennen oder zu löschen - zB: über eine Konsolen Rescue Sitzung - als Prozess im SYSTEM Kontext während des Betriebs lässt Windows das Verschieben oder Löschen nicht zu

Power BI Desktop installieren

  • msi ist deprecated / zumindest laut einer Microsoft Seite / \\vboxsrv\tmp entsprechend anpassen
if exist C:\PowerBI_installed.txt goto Ende

start /wait \\vboxsrv\tmp\PBIDesktopSetup_x64.exe /s ACCEPT_EULA=1

if %ERRORLEVEL% EQU 0 echo > C:\PowerBI_installed.txt


:Ende
  • Deinstallation mit:
\\vboxsrv\tmp\PBIDesktopSetup_x64.exe /s /uninstall
Diese Website verwendet Cookies. Durch die Nutzung der Website stimmen Sie dem Speichern von Cookies auf Ihrem Computer zu. Außerdem bestätigen Sie, dass Sie unsere Datenschutzbestimmungen gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information
know-how/windows.1664439530.txt.gz · Zuletzt geändert: 2022/09/29 10:18 von cc