Skip to content

Instantly share code, notes, and snippets.

View f-bader's full-sized avatar

Fabian Bader f-bader

View GitHub Profile
@f-bader
f-bader / Get-ADCluster.ps1
Created October 19, 2017 07:48
List all Microsoft Failover Cluster computer objects
Get-ADComputer -Filter { servicePrincipalName -like "MSServerCluster*"} | Select-Object DNSHostName
@f-bader
f-bader / TFSIdentSyncHistory.sql
Created November 9, 2017 14:18
Query TFS Identity Synchronization job history
SELECT
[QueueTime],
[StartTime],
[EndTime],
[Result],
[QueuedReasons] = CASE jobHist.[QueuedReasons]
WHEN 1 THEN N'Scheduled'
WHEN 2 THEN N'Manual'
ELSE 'Unknown'
END,
@f-bader
f-bader / ClearKerberosComputerTicketsAndCertutilCache.ps1
Created December 5, 2017 13:57
Clear Computer Kerberos tickets and certutil cache
# Clear Computer Kerberos tickets
klist -li 0x3e7 purge | Out-Null
# Clear certutil cache
certutil -f -policyserver * -policycache delete | Out-Null
Import-Module ADSync
# Your AAD Credentials
$Credential = Get-Credential
# Disable the deletion threshold
Disable-ADSyncExportDeletionThreshold -AADCredential $Credential
# Sync changes
Start-ADSyncSyncCycle -PolicyType Delta
# Enable deletion threshold with default value of 500
Enable-ADSyncExportDeletionThreshold -AADCredential $Credential -DeletionThreshold 500
function ConvertFrom-Xml {
<#
.SYNOPSIS
Converts XML object to PSObject representation for further ConvertTo-Json transformation
.EXAMPLE
# JSON->XML
$xml = ConvertTo-Xml (get-content 1.json | ConvertFrom-Json) -Depth 4 -NoTypeInformation -as String
.EXAMPLE
# XML->JSON
ConvertFrom-Xml ([xml]($xml)).Objects.Object | ConvertTo-Json
@f-bader
f-bader / Get-MyAzureRmAutomationHybridWorkerGroup.ps1
Created January 29, 2018 08:45
Select all Hybrid Workers within the same Hybrid Worker Group as the current computer
$ComputerSystem = (Get-CimInstance Win32_ComputerSystem)
$FqDn = "$($ComputerSystem.Name).$($ComputerSystem.Domain)"
$HybridWorkerGroup = Get-AzureRmAutomationAccount | Get-AzureRMAutomationHybridWorkerGroup | Where-Object { $FqDn -in $_.RunbookWorker.Name }
$HybridWorkerGroup.RunbookWorker.Name
@f-bader
f-bader / InviteAzureUser.ps1
Created January 29, 2018 15:10
Create invite URL for Azure B2B
# Use Azure AD Username
$User = "AzureUsername"
$TargetTenant = "TargetTenant"
# Login
$Cred = Get-Credential
Connect-AzureAD -Credential $cred
# Generate Invitation, but do not send
$Invitation = New-AzureADMSInvitation -InvitedUserEmailAddress $User -InvitedUserDisplayName $User -InviteRedirectUrl "https://portal.azure.com/$($TargetTenant)" -SendInvitationMessage $false
# Copy redeem URL to clipboard
$Invitation | Select-Object –ExpandProperty InviteRedeemUrl | clip
USE [DATENBANK]
SELECT
[UserName] = CASE princ.[type]
WHEN 'S' THEN princ.[name]
WHEN 'U' THEN ulogin.[name] COLLATE Latin1_General_CI_AI
END,
[UserType] = CASE princ.[type]
WHEN 'S' THEN 'SQL User'
WHEN 'U' THEN 'Windows User'
END,
@f-bader
f-bader / Enable-OpenSSHServer.ps1
Created May 3, 2018 17:49
OpenSSH Server auf Windows 1709+ aktivieren
# OpenSSH Server installieren
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Dienst starten
Start-Service sshd
# Starttyp auf "Automatisch" stellen
Set-Service sshd -StartupType Automatic
Set-Service ssh-agent -StartupType Automatic
@f-bader
f-bader / ARMClient.exe.config
Last active July 30, 2018 11:32
Proxy, proxy on the wall
<configuration>
<system.net>
<defaultProxy>
<proxy usesystemdefault="false" autoDetect="false" proxyaddress="http://myproxy.local.bader.cloud:3128" bypassonlocal="true"/>
<bypasslist>
<add address="[a-z]+\.local\.bader\.cloud$" />
</bypasslist>
</defaultProxy>
</system.net>
</configuration>