This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
WHO Searches AD for user information. | |
.DESCRIPTION | |
If an exact account name is found it will be shown. If not a search will be performed. Fields searched are | |
sAMAccountName, Name, and Title | |
.PARAMETER Search | |
User to look for in AD. | |
.PARAMETER RetrieveHostname | |
Get the hostname for the resolved user(s). More precisely: gets computer objects in AD whose description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function UserPhoto ($user, [int]$width, [int]$height) { | |
$user_data = ([adsisearcher]"(&(objectClass=user)(sAMAccountName=$user))").FindAll() | |
$stream = [System.Io.MemoryStream]::new($user_data.Properties["thumbnailphoto"][0]) | |
$img = [System.Drawing.Image]::FromStream($stream) | |
if ($width -or $height) { | |
if (-not $width) { | |
$width = ($img.Width / $img.height) * $height | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The below code is a somewhat modified version of original work from | |
# https://gist.github.com/idavis/856603/818f50f1d6d862ca5458e5b87bca034e567b387f | |
# All credit to the author. | |
function Invoke-AsOtherUser { | |
[CmdletBinding()] | |
param ( | |
[parameter(Mandatory = $true)][PSCredential] $Credentials, | |
[parameter(Mandatory = $true)][ScriptBlock] $ScriptBlock | |
) |