Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Wright discoposse

View GitHub Profile
@discoposse
discoposse / C2OS-Error-on-Windows-with-vagrant
Created Jul 24, 2013
This is the install log during the vagrant deployment on a Windows host running Virtual Box
View C2OS-Error-on-Windows-with-vagrant
PS C:\users\ewright\Documents\VirtualBoxProjects\Couch_to_OpenStack> vagrant up
Bringing machine 'controller' up with 'virtualbox' provider...
[controller] Importing base box 'precise64'...
←[0K[controller] Matching MAC address for NAT networking...
[controller] Setting the name of the VM...
[controller] Clearing any previously set forwarded ports...
[controller] Fixed port collision for 22 => 2222. Now on port 2200.
[controller] Creating shared folders metadata...
[controller] Clearing any previously set network interfaces...
[controller] Preparing network interfaces based on configuration...
@discoposse
discoposse / SplitLogs.ps1
Created Sep 29, 2011
PowerShell - split large text/log file
View SplitLogs.ps1
#############################################
# Split a log/text file into smaller chunks #
#############################################
#
# WARNING: This will take a long while with extremely large files and uses lots of memory to stage the file
#
# Set the baseline counters
#
# Set the line counter to 0
@discoposse
discoposse / gist:1183443
Created Aug 31, 2011
Move Windows 7 Active Directory Computers based on IP Address
View gist:1183443
################################################################################
# PowerShell routine to move Windows 7 Computers into OU structure based on IP #
################################################################################
#####################
# Environment Setup #
#####################
#Add the Quest PowerShell snapin
Add-PsSnapIn Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
View PowerShell - Get a list of "old" computers in Active Directory
# Requires ActiveRoles CmdLets from Quest Software (They're free and awesome) - http://www.quest.com/powershell/activeroles-server
$old = (Get-Date).AddDays(-60) # Modify the -60 to match your threshold
Get-QADComputer -IncludedProperties pwdLastSet -SizeLimit 0 | where { $_.pwdLastSet -le $old }
View PowerShell - Get serial numbers for computers in Active Directory
# Requires ActiveRoles CmdLets from Quest Software (They're free and awesome) - http://www.quest.com/powershell/activeroles-server.aspx
Get-QADComputer -searchroot "OU=yourcomputerOUname,dc=yourdomain,dc=com" -SizeLimit 0 |
ForEach-Object {
$hostname = $_.name
$serialnumber = (Get-WMIObject Win32_BIOS -computer $hostname -ErrorAction SilentlyContinue).SerialNumber
if (-not $serialnumber) {
Add-Content d:\logfiles\offlinehosts.txt "$hostname is in offline"
}
else {
Write-Host "$hostname,$serialnumber" # output to screen
View PowerShell - Finding users with password expiry in under 14 days and sending an email reminder
# Requires ActiveRoles CmdLets from Quest Software (They're free and awesome) - http://www.quest.com/powershell/activeroles-server.aspx
Get-QADUser -SizeLimit 0 | Select-Object samAccountName,mail,PasswordStatus |
Where-Object {$_.PasswordStatus -ne "Password never expires" -and $_.PasswordStatus -ne "Expired" -and $_.PasswordStatus -ne "User must change password at next logon." -and $_.mail -ne $null} |
ForEach-Object {
$today = Get-Date
$logdate = Get-Date -format yyyyMMdd
$samaccountname = $_.samAccountName
$mail = $_.mail
$passwordstatus = $_.PasswordStatus
$passwordexpiry = $passwordstatus.Replace("Expires at: ","")