Home » Archive by category 'Scripts'
Deploy wireless settings with Key using netsh script and GPO
  Windows 2008 has built in policy GPO for wireless setting management. You can configure your network setting using Certificates. It is the most recommended and secure way But if you like to deploy the wireless settings using static key, you will have to use other way. The steps bellow describe the way to deploy Wireless LAN settings with a Pre-Shared Key The purpose is to Automate Adding Wireless Profile in Windows. Preparations Configure Wireless settings on one workstation Read more
Shut Down Exchange 2010 DAG member
  While performing maintenance to Exchange 2010 DAG server you should first remove the DAG member from DAG group.Other wise you may have unwanted DB failovers and many other unexpected issue that may affect company mail services availability Shutting Down DAG Members The Exchange 2010 high availability solution is integrated with the Windows shutdown process. If an administrator or application initiates a shutdown of a Windows server in a DAG that has a mounted database that's replicated Read more
Some Exchange 2010sp1 power shell scripts part1
  Get Quota report Get-Mailbox | Format-Table alias, *quota Delete message from Mailbox get-mailbox -resultsize unlimited | search-mailbox -SearchQuery "Subject:ABDCEV'" -DeleteContent Turn Off firewall on all profiles netsh advfirewall set allprofiles firewallpolicy allowinbound,allowoutbound Exchange 2007 - check DB copy status. Get-StorageGroupCopyStatus -StandbyMachine mtvmail01 Message Tracking log to csv (| Select Sender, Recipients, TimeStamp, MessageSubject) Get-MessageTrackingLog Read more
Send Email Powershell script
  Some times we need to use PS script to send email, script can be used in Task Scheduler or any other program BatchFile to run script: Create *.bat file C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -PSConsoleFile "C:Program FilesMicrosoftExchange Serverbinexshell.psc1" -noexit -command ". C:scriptslocationscriptname.ps1"   PS Script to send mail: Create  .ps1 file $filename = “c:filelocationHtmlFIleyouwant torecieve.html” $smtpServer = “SMTP Read more
How to update exchange 2007 Offline Address List
  You can update OAB by 2 ways via EMS or using Power Shell 1 To update via  EMS Open EMC>Organizational Configuration>Mailbox>Offline Address Book tab. Right click on desired Address Book and press update. 2. Via Power Shell Type: Update-OfflineAddressBook –Identity “Address List Name” To update all Address Books type : Get-OfflineAddressBook | Update-OfflineAddressBook     Read more
Useful AD PowerShell Commands
Finding Disabled Users: get-qaduser –disabled Create a new Active Directory user: new-QADUser -name '<User CN>' -parentContainer '<Parent DN>' -UserPassword '<Password>' -FirstName '<User First Name>' -LastName '<User Last Name>' -UserPrincipalName '<User UPN>' Create multiple users in Active Directory: $parentDN = "<ParentDN>" $strPass = "userPaswd" For ($i = 1; $i -le 1000; $i++) { $strUserName = "User" + $i New-QADUser -name $strUserName -parentContainer Read more
Move Domain Controller to other site – PowerShell

$dcname = <DomainDNSName>
$newSite = "NewSite Name"
$context = New-Object
System.DirectoryServices.ActiveDirectory.DirectoryContext(‘DirectoryServer’, $dcname)
$dc =
[System.DirectoryServices.ActiveDirectory.DomainController]::getDomainController ($context)
$dc.MoveToAnotherSite($newSite)

 

Where DomainDNSName – Enter your DNS domain name

PowerShell Script To Create Snapshot of All VMs – Hyper-V
$VSMgtSvc=Get-WmiObject -ComputerName localhost
-NameSpace "rootvirtualization"
-Class "MsVM_virtualSystemManagementService"
get-wmiobject -computername localhost -Namespace rootVirtualization
-query "Select * from MSVM_Computersystem where Description like
'%Virtual%' " | foreach-object {$VSMgtSvc.psbase.invokeMethod
("CreateVirtualSystemSnapshot",@($_,$Null,$null)) }
Create Group Using PowerShell ADUC, dsadd or admod
Creating a Group Using a graphical user interface Open the Active Directory Users and Computers . In the left pane, browse to the parent container of the new group, right-click on it, and select New Group. Enter the name of the group and select the group type (global, domain local, or universal) and group type (security or distribution). Click OK. Using dsadd in command-line interface dsadd group "<GroupDN>" -scope <GroupScope> -secgrp yes|no -desc "<GroupDesc>" Where <GroupDN> Read more
PowerShell script to find all Local Users on a remote computer
$strComputer = "ComputerName" $computer = [ADSI]("WinNT://" + $strComputer + ",computer") $computer.name $Users = $computer.psbase.children |where{$_.psbase.schemaclassname -eq "User"} foreach ($member in $Users.psbase.syncroot) {$member.name} Read more