Skip to content

Instantly share code, notes, and snippets.

View norman-bauer's full-sized avatar

Norman Bauer norman-bauer

View GitHub Profile
@norman-bauer
norman-bauer / CreateSqlUserWithSid.sql
Created April 13, 2018 06:26
Create SQL User with given SID
create login your_sql_loginname with password = 'your_sql_loginspassword', sid = {your_sql_user_sid}
@norman-bauer
norman-bauer / UserAccountPicture.cs
Created April 13, 2018 06:36
UserAccountPicture.exe C# version
using System;
using System.Runtime.InteropServices;
namespace useraccountpicture
{
class Program
{
[DllImport("shell32.dll", EntryPoint = "#262", CharSet = CharSet.Unicode, PreserveSig = false)]
public static extern void SetUserTile(string username, int notneeded, string picturefilename);
@norman-bauer
norman-bauer / UserAccountPicture.vb
Created April 13, 2018 06:37
UserAccountPicture.exe VB.Net version
Imports System.Runtime.InteropServices
Module useraccountpicture
<DllImport("shell32.dll", EntryPoint:="#262", CharSet:=CharSet.Unicode, PreserveSig:=False)> _
Private Sub SetUserTile(ByVal username As String, ByVal notneeded As Integer, ByVal picturefilename As String)
End Sub
Sub Main(ByVal args As String())
If (args.Length = 2) Then
@norman-bauer
norman-bauer / SavePictureToAD.vbs
Last active April 13, 2018 07:20
Upload a user picture from file to Active Directory with vbScript.
Function SavePictureToAD(szADsPath, szLoadFileName)
Dim objUser, bytesRead, adoStreamRead
Const adTypeBinary = 1
Set adoStreamRead = CreateObject("ADODB.Stream")
adoStreamRead.Type = adTypeBinary
adoStreamRead.Open
adoStreamRead.LoadFromFile szLoadFileName
bytesRead = adoStreamRead.Read()
adoStreamRead.Close
@norman-bauer
norman-bauer / SavePictureToAdFromUrl.vbs
Last active April 13, 2018 07:20
Upload a user picture from url to Active Directory with vbScript.
Function SavePictureToAdFromUrl(szADsPath, szUrl)
Dim objUser, bytesRead, adoStreamRead
Const adTypeBinary = 1
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", szUrl, False
xml.Send
If xml.status = 200 Then
Set adoStreamRead = CreateObject("ADODB.Stream")
@norman-bauer
norman-bauer / SetUserAccountPictureFromAD.vbs
Last active April 13, 2018 07:20
How to display Active Directory stored user account pictures in Windows?
Function LoadPictureFromAD(szADsPath, szSaveFileName)
Dim objUser, bytesRead, adoStreamWrite
Const adTypeBinary = 1, adSaveCreateOverWrite = 2
Set objUser = GetObject(szADsPath)
bytesRead = objUser.Get("thumbnailPhoto")
Set adoStreamWrite = CreateObject("ADODB.Stream")
adoStreamWrite.Type = adTypeBinary
adoStreamWrite.Open
@norman-bauer
norman-bauer / GetSqlSids.sql
Last active April 13, 2018 07:21
Get all SIDs from SQL Server
use master
go
select sid, name, dbname from syslogins
@norman-bauer
norman-bauer / Configure-SendAsPermissions.ps1
Last active April 13, 2018 07:21
Configure SendAs Permissions on an Office365 Distribution Group using PowerShell
Set-ExecutionPolicy RemoteSigned
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
$DistributionGroup = "somerandomdistributiongroup@normanbauer.com"
@norman-bauer
norman-bauer / Get-BitlockerInformation.vbs
Last active August 23, 2019 08:54
Shows information on Bitlocker encrypted volumes. Run from an elevated command prompt.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume",,48)
Dim arEncryptionMethod
arEncryptionMethod = Array("None", "AES 128 With Diffuser", "AES 256 With Diffuser", "AES 128", "AES 256", "HARDWARE ENCRYPTION", "XTS AES 128", "XTS AES 256")
Dim arProtectionStatus
arProtectionStatus = Array("Protection Off", "Protection On", "Protection Unknown")
@norman-bauer
norman-bauer / BasicEWSSoapRequest.xml
Created August 23, 2019 09:03
This is an example on how to connect to Exchange EWS using xml and vbs.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" Traversal="Shallow">
<ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
</ItemShape>
<ParentFolderIds>
<t:DistinguishedFolderId Id="deleteditems"/>
</ParentFolderIds>