Skip to content

Instantly share code, notes, and snippets.

View danblank000's full-sized avatar

Dan Blank danblank000

View GitHub Profile
@danblank000
danblank000 / Get_Computer_Info.ps1
Created August 18, 2017 10:35
Find useful information about a machine
Function Model
{
$Description = Get-WmiObject -Class Win32_OperatingSystem -Computer $Computer -Credential $Credentials
$Model = get-wmiobject -class "Win32_Computersystem" -computer $Computer -Credential $Credentials
$Ram = ($Model.TotalPhysicalMemory/1GB)
$Ram = [Math]::Round($Ram, 2)
Write-host
Write-host "Computer :" $Model.Name.ToUpper()
@danblank000
danblank000 / Capitalise_User_Details.ps1
Last active August 18, 2017 12:53
Capitalise title, department, givenname, surname and displayname for all users in Active Directory
$users = get-aduser -Filter * -SearchBase #"ou=OU,dc=MYD,dc=local"
foreach ($user in $users)
{
$person = get-aduser $user -Properties title, department, givenname, surname, displayname | select displayname, title, department, givenname, surname
$displayname = ($person.displayname).ToString()
$title = ($person.title).ToString()
$department = ($person.department).ToString()
$givenname = ($person.givenname).ToString()
@danblank000
danblank000 / What_Machine_User_Logged_In_To.ps1
Created August 19, 2017 09:00
Queries share connections to see what machine a users is currently logged in to
Import-Module activedirectory
write-host "**************************************************************"
Write-Host "`nThis script will tell you what computer a user is logged in to" -ForegroundColor Yellow -BackgroundColor Black
write-host "`n**************************************************************"
$i = 0
#sets up credentials
$myusername = "**DOMAIN**\" + [Environment]::UserName
@danblank000
danblank000 / Staff_Photos.ps1
Created August 20, 2017 09:27
Adding Multiple or Individual Photos to the GAL
<#
######
IMPORT PHOTOS EN-MASSE BASED ON THE PHOTOS BEING NAMED AFTER THE RELEVANT USERS
e.g. for staff members Alan Alanson, Barry Barryson, Charles Charleson,
the photos would need to be name "Alan Alanson.jpg", "Barry Barryson.jpg", "Charles Charleson.jpg".
#####
#>
$PhotoPath = "\\SERVER\SHARE\photos\Outlook\*.*"
ForEach ($PhotoFile in gci $PhotoPath)
@danblank000
danblank000 / NI_Checker.PS1
Last active August 22, 2017 05:36
Cmdlet with GUI to query a specific value against a Database
Add-Type -AssemblyName System.Windows.Forms
$NIChecker = New-Object system.Windows.Forms.Form
$NIChecker.Text = "Form"
$NIChecker.TopMost = $true
$NIChecker.Width = 304
$NIChecker.Height = 289
$Label = New-Object system.windows.Forms.Label
$Label.Text = "Enter the National Insurance Number below"
@danblank000
danblank000 / Find_Current_Queries.sql
Created August 22, 2017 10:23
See what queries are currently running
SELECT sqltext.TEXT
, req.session_id
, req.status
, req.command
, req.cpu_time
, req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
AS sqltext