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
# Gets a list of groups that the user is a member of from the current Windows identity token. | |
# Param1: $domain - Boolean value. Return group names with domain or not. | |
# e.g. true = "BUILTIN\Authenticated Users", false = "Authenticated Users". | |
Function Get-Membership($domain) | |
{ | |
$groups = @() | |
foreach ($group in [System.Security.Principal.WindowsIdentity]::GetCurrent().Groups) | |
{ | |
$grp = $group.Translate([System.Security.Principal.NTAccount]).ToString() |
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
# Returns a date string based on an AD attribute (like lastlogon, or accountexpires). | |
# Param1: $addate - AD attribute date value. | |
Function Get-ADDate($addate) | |
{ | |
Try | |
{ | |
$formatteddate = [datetime]::FromFileTime($addate).Date.ToString() | |
} | |
Catch |
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
/// <summary> | |
/// Gets the DirectoryEntry object of the LDAP distinguishedname passed in, using the current user credentials. | |
/// </summary> | |
/// <param name="path">A distinguishedname of the object you wish to get the DirectoryEntry for.</param> | |
/// <returns></returns> | |
private static DirectoryEntry GetDirectoryEntry(string path) | |
{ | |
DirectoryEntry de = new DirectoryEntry(); | |
de.Path = path; | |
de.AuthenticationType = AuthenticationTypes.Secure; |
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
#Set UPN for all users with mobile phone numbers to email address | |
Get-ADuser -Filter * -Properties mobilephone, mail | where {$_.mobilephone -and $_.mail -ne $_.userPrincipalName} | ForEach-Object {Set-ADuser -Identity $_.ObjectGUID -UserPrincipalName $_.mail} | |
#Set UPN for all users to email address | |
Get-ADuser -Filter * -Properties mail | where {$_.mail -ne $_.userPrincipalName} | ForEach-Object {Set-ADuser -Identity $_.ObjectGUID -UserPrincipalName $_.mail} |
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 Load-Form | |
{ | |
$Form.Controls.Add($TBComputerName) | |
$Form.Controls.Add($GBComputerName) | |
$Form.Controls.Add($ButtonOK) | |
$Form.Add_Shown({$Form.Activate()}) | |
[void] $Form.ShowDialog() | |
} | |
Function Set-OSDComputerName |
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
pushd %~dp0 | |
set _bcu=BiosConfigUtility.exe | |
if /I "%PROCESSOR_ARCHITECTURE%" EQU "AMD64" set _bcu=BiosConfigUtility64.exe | |
"%_bcu%" /nspwdfile:"%~dp0BIOSPW.bin" /set:"%~dp0ProBook6470bConfig.cfg" | |
IF %ERRORLEVEL% NEQ 0 "%_bcu%" /cspwdfile:"%~dp0BIOSPW.bin" /set:"%~dp0ProBook6470bConfig.cfg" | |
popd |
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 Get-ComputerADSite() | |
{ | |
<# | |
.Synopsis | |
Get the computers current AD site from the computer Netlogon information. | |
.Example | |
Get-ComputerADSite | |
.Notes |
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
#Requires -Version 3 | |
Function Get-TimezoneFromOffset() | |
{ | |
<# | |
.Synopsis | |
A function that gets the timezones that match a particular offset from UTC | |
.Parameter UTCOffset | |
A string containing offset time you require. This must match the form +NN:NN or -NN:NN. |
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 Connect-ExchangeOnline { | |
<# | |
.Synopsis | |
A function that connects to the Exchange online system. | |
.Parameter Credential | |
A credential object with rights to connect to the Exchange server. This parameter is mandatory. | |
.Parameter AllowClobber | |
Boolean value of whether the imported session will clobber existing commands. Defaults to True. |
OlderNewer