Donnerstag, 28. Januar 2010

Show LoginTime when Client logs on to Active Directory Domain

This Script will generate the following Informations automaticly:

Show LoginTime when Client logs on to Active Directory Domain, Domain Server,
Password Age, etc.




function loginmail()

$shortuser = right(@userid,len(@userid)-0)
$objEmail=CreateObject('CDO.Message')
$objEmail.From = "Benutzer_LOGIN "
$objEmail.To = "NameIT@@Domain.TLD"
$objEmail.Subject='LOGIN_Benutzer '+$shortuser+', '+$shortuser2+'. hat sich an '+@wksta+' eingeloggt'
$objEmail.Textbody='-----------[ LOGIN ]-----------------'+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'Benutzer: '+@userid+''+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'Workstation: '+@wksta+''+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'IP: '+@ipaddress0+''+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'Uhrzeit: '+@TIME+''+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'Datum: '+@DATE+''+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'Logon Server: '+@LServer+''+chr(10)+chr(10)
$objEmail.Textbody=$objEmail.Textbody + '-----------[ SYSTEM INFO ]------------'+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'Passwordalter: '+@PWAge+''+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'Betriebssystem: '+@ProductType+''+chr(10)
$objEmail.Textbody=$objEmail.Textbody + 'Servicepack: '+@CSD+''+chr(10)
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing").value = 2
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver").value = "your_SMTP_Server"
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").value = 1
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername").value = "LoginName_for_SMTP_Server"
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword").value = "Password_for_Authentication_to_SMTP_Server"
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport").value = 25
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl").value = False
$objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout").value = 60
$objEmail.Configuration.Fields.Update
$objEmail.Send
endfunction

-------------------------------------

-----------[ LOGIN ]-----------------
Benutzer: Thomas.Mann
Workstation: WorkstationName
IP: 192.192.192.192
Uhrzeit: 12:00:01
Datum: 2010/01/01
Logon Server: \\DomainControllerName01

-----------[ SYSTEM INFO ]------------
Passwordalter: 150 Days
Betriebssystem: Windows XP Professional
Servicepack: Service Pack 3

Dienstag, 26. Januar 2010

Reset Windows Server 2008 Domain Administrator Password

Boot onto DVD of Windows Server 2008
Choose “Repair your computer”
Launch cmd
Go to c:\windows\system32
Rename Utilman.exe to Utilman.exe.bak
Copy cmd.exe to Utilman.exe
Reboot on Windows
Do the keyboard shortcut Windows + U when on the logon screen
net user administrator Newpass123 inside the cmd
log on with the domain admin account and this new pass
change the password to remember it if needed
Reboot on the DVD to put back the original Utilman.exe

Thx to mathieu chateau

Samstag, 9. Januar 2010

Remove Recovery Points XX Days

This Script allowes you to remove Recovery Points on a Microsoft Data Protection Manager 2007 Server, after XX Days.

Usage: RemoveRecoverypoints.PS1 "YourDPMserver" X
e.g.: RemoveRecoverypoints.PS1 "DPM01" 5
This will Remove All Recoverypoints, except those which are 5 max. days or less old.


param([string] $dpmname, [int32] $days )
function Usage()
{
write-host
write-host "Usage::"
write-host "RemoveRecoveryPoints.ps1 "DPMServername" Days(In int)"
write-host
}
if(("-?","-help") -contains $args[0])
{
Usage
exit 0
}
if(!$dpmname)
{
$dpmname = read-host "DPMServerName:"
}
if(!$days)
{
$days = read-host "Number of Days"
}
$pgList = Get-ProtectionGroup $dpmname
Foreach($pg in $pgList)
{
$Name = $pg.FriendlyName
Write-Host "Getting Data Source list for PG $Name..."
$dsList = Get-Datasource $pg
Foreach($ds in $dsList)
{
$Name = $ds.Name
Write-Host "Getting Recovery point list for Data-Source $Name ..."
$rpList = Get-RecoveryPoint $ds
Foreach($rp in $rpList)
{
$date = Get-Date
$datediff = $date - $rp.RepresentedPointInTime
$rpDays = $datediff.Days
Write-Host "Recovery Point is $rpDays days old "
if($rpDays -ge $days)
{
Write-Host "Removing Recovery Point older than $rpDays"
Remove-RecoveryPoint -RecoveryPoint $rp
}
}
}
}