Skip to content

Instantly share code, notes, and snippets.

View cainejunkazama's full-sized avatar

Sascha Trebbin cainejunkazama

  • Berlin, Germany
View GitHub Profile
@cainejunkazama
cainejunkazama / net_use
Last active December 20, 2015 15:38
Überprüfen eines Netzwerkpfads und anschließendes Einbinden als Netzlaufwerk
@echo off
rem Hier wird der Pfad für die Freigabe eingetragen...
set freigabe=
rem ... und hier der gewünschte Buchstabe (NUR den Buchstaben)
set laufwerk=
rem Wir überprüfen, ob das Laufwerk schon hinzugefügt ist...
rem ...und löschen es dann
if exist %laufwerk%: net use %laufwerk%: /delete
@cainejunkazama
cainejunkazama / create-user
Created August 6, 2013 06:54
Powershell-Funktion zum automatisierten Erstellen von generischen Benutzern innerhalb einer Active Directory Domäne.
#gefunden auf http://tompavaa.blogspot.de/2011/03/create-multiple-users-in-ad-using.html
Import-Module ServerManager
Add-WindowsFeature 'RSAT-AD-PowerShell'
function Create-User()
{
[CmdletBinding()]
param(
[string]$BaseUserName = "testuser", # Base name for the users
<#
.SYNOPSIS
Create a simple, yet good looking Employee Directory in HTML format.
.DESCRIPTION
Run this script and create a HTML based Employee Directory that your users
can use to locate each other's information. Supports title, extension, cell,
fax, description, manager, home page link and email. Also fully utilizies Active
Directory's ability to store photos and you will have the choice of how you
want to display those pictures, either hover over or click their first name or
last name to see the picture (you choose).
@ECHO OFF
ECHO Resetting Volume Mixer Settings…
ECHO You will be temporarily be UNABLE to hear any audio.
REM The next two lines will stop the services responsible for audio.
NET STOP Audiosrv
NET STOP AudioEndpointBuilder
REM Let’s replace the settings (stored in a registry entry) with an empty entry.
<#
.SYNOPSIS
Map-AD will create a visual representation of your AD structure
.DESCRIPTION
Map-AD will create a visual representation of the Container and Organizational Unit structure within your Active Directory Domain starting from the root, or from a specified OU.
.PARAMETER OU
Represents the OU that you would like to start the mapping from.
.PARAMETER Name
A switch to toggle between outputting distinguished names and just names of OUs and containers
.EXAMPLE
REM Check Windows Version
ver | findstr /i "5\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2000
ver | findstr /i "5\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "5\.2\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_2003
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." > nul
@echo off
cls
REM Identify OS.
ver | find /i "version 6.2." > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows 8
ver | find /i "version 6.1." > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows 7
ver | find /i "version 6.0." > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows Vista
ver | find /i "version 5.1." > nul
@echo off
REM This process will often fix a PC that appears to have network connectivity, but won't browse the web
REM This resets the Winsock and TCP/IP stacks
REM The ip/ipv4 is labeled differently in XP/Vista/7. You'll get one error on one of these when launching
REM System requires reboot after this batch
netsh winsock reset catalog
netsh int ip reset reset.log
netsh int ipv4 reset reset.log
<#
.SYNOPSIS
Converts bytes to a more readable KB, MB, GB, or TB
.DESCRIPTION
Format-Bytes takes a bytes sized input and formats it to be KB, MB, GB, or TB depending on its size.
.PARAMETER $Num
The number to convert to KB, MB, GB, or TB.
.EXAMPLE
Format-Bytes 123456789
$KBID = "KB # for uninstall"
function Remove-Update {
$HotFixes = Get-HotFix
foreach ($HotFix in $HotFixes)
{
if ($KBID -eq $HotFix.HotfixId)