Changed the theme because I can,
forgot to check my customisation that I put in before
google's code says use
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?lang=css&skin=sunburst"></script>
which causes a xml error where the delimiter ; is missing
change
& to &
<pre><script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?lang=css&skin=sunburst"></script>
</pre>
sigh.. 40 mins lost
Saturday, January 25, 2014
Comparing AD object security
$tango=(Get-Acl "AD:$((Get-ADUser tango).distinguishedname)").access | select identityreference, accesscontroltype $cash=(Get-Acl "AD:$((Get-ADUser cash).distinguishedname)").access | select identityreference, accesscontroltype compare $tango $cashstill couldn't get to root cause of the issue.(automated system cant update account)
Getting your Apple USB Ethernet Adapter to work on your Windows 8 64-bit computer
- Goto http://www.asix.com.tw/
- support/downloads
- Family "USB 2.0 to Fast Ethernet"
- Product "AX88772A"
- Download the windows 8.0 / 8.1 driver
- In device manager choose update driver for the 'Apple USB Ethernet'
- follow the 'Have Disk' method to the driver
- choose the 'ASIX AX88772A....' driver
- enjoy your internetz
Sort\Move files based on first letter
#
# Sort Files based on first letter
#
#
$path='P:\vid\Movies'
# Issue : anything starting with "the" can cause the Q-Z to fill up
# comment out if not required
$thefiles=Get-ChildItem $path -af the*.* -recurse -exclude *.txt,*.jpg,*.nfo
foreach($file in $thefiles){
ren $file ($file.Name).Substring(4)
}
#
#
#
Get-ChildItem $path -af -recurse -exclude *.txt,*.jpg,*.nfo,*.xml | Where-Object {$_.Name -match "^[a-e]"} | ForEach-Object {move $_.fullname P:\sorted\A-E}
Get-ChildItem $path -af -recurse -exclude *.txt,*.jpg,*.nfo,*.xml | Where-Object {$_.Name -match "^[f-k]"} | ForEach-Object {move $_.fullname P:\sorted\F-K}
Get-ChildItem $path -af -recurse -exclude *.txt,*.jpg,*.nfo,*.xml | Where-Object {$_.Name -match "^[l-p]"} | ForEach-Object {move $_.fullname P:\sorted\L-P}
Get-ChildItem $path -af -recurse -exclude *.txt,*.jpg,*.nfo,*.xml | Where-Object {$_.Name -match "^[Q-Z]"} | ForEach-Object {move $_.fullname P:\sorted\Q-Z}
Wednesday, November 27, 2013
more commands and scripts
getting remote command line\process path
wmic /node:10.1.2.3 PROCESS get Caption,Commandline,Processid
IIS Logs (from friend)
Purpose: Removes IIS log files older than 30 days and sets the compress switch on all files older than 3 days. This is to save space on the log drive and
automatically manage IIS log file retention on Exchange CAS servers.
#>
# Variables
$dateNow = (Get-Date).ToString("HHmm_ddMMyyyy")
$deleteDate = (Get-Date).addDays(-30)
$CompressDate = (Get-Date).addDays(-3)
#MAIN SCRIPT
# Cleanup IIS files older than 30days old
Get-ChildItem D:\IIS_Logs -Recurse | where {$_.CreationTime -le $deleteDate -and $_.Attributes -notlike "*Directory*"} | Remove-Item -force
# Compress IIS files created more than 3days ago (omit Directories)
$IISFiles = Get-ChildItem D:\IIS_Logs -Recurse | where {$_.CreationTime -le $CompressDate -and $_.Attributes -notlike "*Compress*" -and $_.Attributes -notlike "*Directory*"} | Select *
foreach($file in $IISFiles){
Invoke-WmiMethod -Path "CIM_DataFile.Name='$($File.FullName)'" -Name compress -Confirm:$false
}
Monday, November 4, 2013
powershell filtering two arrays and using text and variables
Comparing two list/Array/ and work from that...
# # Active FPS list # $OUName= 'OU=File and Print,OU=Servers,OU=MOE Servers,DC=Kool,DC=Kids' $TheComputers = Get-ADComputer -filter * -searchbase $OUName # # Exclude File and Print Server #Variables in text.. so I can remember sometimes need brackets othertimes not... @#$@#, , # $ExcludedFPs="PANDA" Write-host Excluded File and Print Server - $ExcludedFPs #Filter the List of objects $AcutalFPStargets=Compare-Object $TheComputers.name $ExcludedFPs | where {$_.sideindicator -eq "<="} | % {$_.inputobject} #now... do stuff foreach ($server in $AcutalFPStargets){
if(!($user.homedirectory -like '*'+($server).name+'*')) $path = "\\"+$server.Name+"\users"
Labels:
array,
compare,
filtering,
powershell,
variables
Tuesday, October 8, 2013
Quick Audit of Active Directory OUs Users
$splat=$null
$Splat = @()
$95days = (get-date).adddays(-95)
$AlltheOus=Get-ADOrganizationalUnit -filter * -SearchBase "OU=Humans,DC=coolkids,DC=local" -Properties CanonicalName
foreach($OU in $AlltheOus) {
$objectCount=(Get-adobject -Filter * -SearchBase $ou.distinguishedname -searchscope Onelevel|Measure-Object).count
$u=Get-ADUser -filter * -searchbase $ou.distinguishedname -Properties passwordneverexpires,passwordlastset -searchscope Onelevel
$total=($u | measure-object).count
$Enabled=($u | where {$_.Enabled} | Measure-Object).count
$Disabled=$total-$Enabled
$nonExpirePassword=($u | where {$_.passwordneverexpires} | Measure-Object).count
$passwordolder90=($u | where {$_.passwordlastset -lt $95days} | Measure-Object).Count
$Splat += New-Object psobject -Property @{
Name=$ou.CanonicalName;
TotalObjects=$objectCount;
TotalUsers=$Total;
Enabled=$Enabled;
Disabled=$Disabled;
PasswordNonExpire=$nonExpirePassword;
Password90days=$passwordolder90;
OU=$OU.Distinguishedname
}
}
$splat | Select-Object Name,TotalObjects,TotalUsers,Enabled,Disabled,PasswordNonExpire,Password90days,OU | Sort-Object name| export-csv C:\temp\QuickOUAudit.csv -NoTypeInformation -force
Subscribe to:
Posts (Atom)