Showing posts with label 2008. Show all posts
Showing posts with label 2008. Show all posts

Tuesday, May 21, 2013

Powershell: Gather all user objects and report lastlogon and lastlogontimestamp to CSV file


Purpose:
Connects to active directory and pulls a list of all user objects and create a report of lastlogon and lastlogontimestamp values

Note: This is something i did around midnight so i need to do further testing on this script to ensure the data is correct and the lastlogon value will only be from the DC the script is running against

  
#Tony Unger
#Scans all user accounts and reports lastlogon and lastlogontimestamp attr.

Import-Module ActiveDirectory

$AllUsers = get-aduser -Filter * -SearchBase "DC=microsoft,DC=Com" -Property SamAccountName,Lastlogon,LastlogonTimeStamp | Select Name,UserPrincipalname,SamAccountName,@{Name='Last Logon Timestamp';Expression={[System.DateTime]::FromFileTime($_.LastLogonTimestamp).ToString('g')}},@{Name='Last Logon';Expression={[System.DateTime]::FromFileTime($_.LastLogon).ToString('g')}}

$AllUsers | Export-Csv -Path "c:\Audit_UsersLastLogon.csv" -NoTypeInformation




Wednesday, April 24, 2013

Enable USB that has been disabled via GPO


Save the following as a batch file and run as a local admin account:


REM
REM


icacls c:\Windows\inf\usbstor.inf /reset
icacls c:\Windows\inf\usbstor.pnf /reset
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies" /v WriteProtect /t REG_DWORD /d 00000000 /f


REM
REM
REM
REM


Note:
This will fix the installation of SP1 for Win7/2008r2 that fails because of usb being disabled.

Monday, July 2, 2012

Move Sql Agent Jobs to a new server

1. Click on Jobs under SQL Server Agent
 
 2. For 2005 click on the Summary Tab, 2008 Object Explorer Details Tab under View
 3. Select the all the jobs you wish to backup listed in the object explorer details tab
 
4. Right Mouse click and select Script Job As -> Create To -> File

 5. Save the sql file to the new server
 
6. Execute the sql generated script on the new server and the jobs should populate


Credit to BrianBeall94706
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=99014

Powershell: Microsoft Graph to add new roles to application registration

PowerShell Script Bulk add new roles to application registration in azure. Update $roles with ,Us...