Friday, January 29, 2016

[O365] Recover messages deleted from Recoverable items folders


To verify the number of items:
Search-Mailbox "user@testtenant.com.br" -TargetMailbox "Discovery Search Mailbox" -TargetFolder "Recover1" -LogLevel Full -SearchDumpsterOnly -LogOnly

To copy the items to another user folder:
Search-Mailbox "user@testtenant.com.br" -TargetMailbox "user2@testtenant.com.br"  -TargetFolder "Recover1" -LogLevel Full -SearchDumpsterOnly

Tuesday, January 26, 2016

[WSRV] Retrieve user details from Active Directory using SID


$strSID="S-1-5-21-500000003-1000000000-1000000003-1001"
$uSid = [ADSI]"LDAP://<SID=$strSID>"
echo $uSid


distinguishedName : {CN=John Doe,OU=Domain Admins,OU=People,OU=xxx,DC=xxx}
Path              : LDAP://<SID=S-1-5-21-500000003-1000000000-1000000003-1001>

[WSRV] Reset the Secure Channel


netdom reset /d:devgroup.contoso.com mywksta


OR


nltest /sc_verify:iammred

ipconfig /flushdns
arp -d *
Get-Service netlogon | restart-service
nltest.exe /sc_verify:<fully.qualified.domain.name.here>


OR

nltest /SC_RESET:<DomainName> - Reset secure channel for <Domain> on <ServerName>

OR

Test-ComputerSecureChannel

Test-ComputerSecureChannel -Repair

Tuesday, January 19, 2016

[EX2013] Collect the virtual directories URLs

Run it directly in the EMS


"### OWA ###" | Out-File c:\url.txt -Append
Get-OwaVirtualDirectory | fl Name,Server,FailbackUrl,InternalUrl,ExternalUrl,*yV* | Out-File c:\url.txt -Append
"### ECP ###"  | Out-File c:\url.txt -Append
Get-EcpVirtualDirectory | fl Name,Server,*Url,*yV*  | Out-File c:\url.txt -Append
"### EWS ###" | Out-File c:\url.txt -Append
Get-WebServicesVirtualDirectory | fl Name,Server,*url,*yV* | Out-File c:\url.txt -Append
"### OAB ###" | Out-File c:\url.txt -Append
Get-OabVirtualDirectory | fl Name,Server,*url*,*yV*  | Out-File c:\url.txt -Append
"### EAS ###" | Out-File c:\url.txt -Append
Get-ActiveSyncVirtualDirectory | fl Name,Server,*url*,*yV*  | Out-File c:\url.txt -Append
"### OA ###"  | Out-File c:\url.txt -Append
Get-OutlookAnywhere | fl Name,Server,*Hostname,*Method*,*SSL*,*yV*  | Out-File c:\url.txt -Append
"### CAS ###"  | Out-File c:\url.txt -Append
Get-ClientAccessServer | fl Fqdn,AutoDiscoverServiceInternalUri,*Site*  | Out-File c:\url.txt -Append
.


(Exchange 2016 only)

"### MAPI ###" | Out-File c:\url.txt -Append
Get-MapiVirtualDirectory | fl Name,Server,*url*,*yV*  | Out-File c:\url.txt -Append

[WSRV] Provisioning a server core domain controller

powershell

$cn = hostname

netdom renamecomputer $cn /NewName:DC1

netsh interface ip set address "Ethernet" static 192.168.10.1 255.255.255.0 192.168.10.254

netsh interface ip add dns "Ethernet" 192.168.10.1

netsh interface ip add dns "Ethernet" 192.168.10.254 index=2


powershell

Install-WindowsFeature AD-Domain-Services

$SafePass = Read-Host "Password" -AsSecureString

Install-ADDSForest -DomainName domain.local -DomainNetbiosName MYDOMAIN -ForestMode Win2012R2 -DomainMode Win2012R2 -InstallDNS -NoDnsOnNetwork -SafeModeAdministratorPassword $SafePass



powershell

Add-DnsServerPrimaryZone -NetworkID "192.168.10.0/24" -ReplicationScope "Forest"


cscript C:\Windows\System32\Scregedit.wsf /ar 0

netsh advfirewall set currentprofile state off

[EX2010] Script to send test messages


To open connectors:

Get-ReceiveConnector |?{$_.Name -like "*defa*"} | Set-ReceiveConnector -PermissionGroups 'AnonymousUsers, ExchangeUsers, ExchangeServers, ExchangeLegacyServers'


To send test messages:

$domain = (Get-AcceptedDomain).name
$fqdn = "$env:computername.$env:userdnsdomain"
$date = Get-Date -UFormat "%m/%d/%Y"
$mbx = Get-Mailbox -RecipientTypeDetails UserMailbox
$tot = read-host "Messages per user"

while ($val -ne $tot) {$val++ ; $mbx | % -Process {Send-MailMessage -To $_.PrimarySmtpAddress -From noreply@$domain -Subject "Test Message from $date - Message # $val" -Body "Please don't reply this message. We are making some tests in our Exchange environment" -SmtpServer $fqdn}}

[AZR] Manage Azure VM IPs


Set static internal IP address:

Get-AzureVM -ServiceName MyCloudService -Name MyAzureVM | Set-AzureStaticVNetIP -IPAddress "10.1.1.4" | Update-AzureVM


Create a new reserved IP:

1. Create the Azure reserved IP:

New-AzureReservedIP -ReservedIPName MyReservedIP -Location "East US"

2. Associate with a cloud service 

Set-AzureReservedIPAssociation -ReservedIPName MyReservedIP -ServiceName MyCloudService 


Convert Dynamic VIP to Reserved IP in a cloud service:

New-AzureReservedIP -ReservedIPName MyReservedIP -Location "East US" -ServiceName MyCloudService 


Remove Reserved IP from the Deployment

Remove-AzureReservedIPAssociation -ReservedIPName MyReservedIP -ServiceName MyCloudService 

[EX2010] Install Exchange in Unattended Mode

Exchange 2010

Setup.com  /mode:Install /roles:ClientAccess,Mailbox,HubTransport /MdbName:IT /DbFilePath:c:\mbx\it.edb /Logfolderpath:c:\logs\it /ExternalCASServerDomain:mail.mydomain.usa /UpdatesDir:C:\Users\Administrator\Downloads\up

https://technet.microsoft.com/en-us/library/aa997281(v=exchg.141).aspx


Exchange 2013

Setup.exe  /mode:Install /roles:ClientAccess,Mailbox /MdbName:IT /DbFilePath:c:\mbx\it.edb /Logfolderpath:c:\logs\it /UpdatesDir:C:\Users\Administrator\Downloads\up  /IAcceptExchangeServerLicenseTerms



Saturday, January 9, 2016

[WSRV] Bulk change AD users password

$pwd = ConvertTo-SecureString -string "Pa$$w0rd" -AsPlainText -force

Get-ADUser -Filter * -SearchScope Subtree -SearchBase "OU=Sports,DC=domain,DC=local" | Set-ADAccountPassword -Reset -NewPassword $pwd

Friday, January 1, 2016

[EX2010] Search Mailbox


Need to assign the management Roles to perform the search-mailbox for the user account from which we are running the cmdlet in exchange 2010 SP1 or greater


Roles:
Mailbox Import Export
Mailbox Search

example:
new-managementroleassignment -Name "test" -role "Mailbox Import Export" -User "username"
new-managementroleassignment -Name "test1" -role "Mailbox Search" -User "username" 


1)To search the emails older than 01/26/2011 from a particular user's mailbox
Search-Mailbox –identity “Usr name” -SearchQuery ‘kind:email AND received:<01/26/2011’

2)To search the emails older that 01/01/2011 from a perticluar user's mailbox and delete them.
Search-Mailbox –identity “Usr name” -SearchQuery ‘kind:email AND received:<01/26/2011’ -DeleteContent -Force  

3)To search the emails from the specific mailbox database which are older than 01/26/2011.
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’

4)To search the emails from the specific mailbox database which are older than 01/26/2011 and delete them.
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’ –DeleteContent  -Force  

5)To delete messages from all the users on a server which are older than 01/26/2011.
Get-mailbox –server “servername” –resultsize unlimited | Search-Mailbox  -SearchQuery ‘kind:email AND received:<01/26/2011’ –DeleteContent  -Force  

6)To search the emails from the specific mailbox database from a perticlar folder in the mailbox
Get-Mailbox –database “database_name” –resultsize Unlimited |  Search-Mailbox  -SearchQuery ‘In:"folder name"

7)Below example searches the mailbox of myuser and copies the search results to the DiscoveryMailbox in the folder my_user_data.
Search-Mailbox -Identity myuser -SearchQuery 'Subject:”project report”' -TargetMailbox "DiscoveryMailbox" -TargetFolder my_user_data

8)Below example searches Myuser's mailbox for messages that contain the words "project details" in the subject and deletes the messages from the source mailbox.
Search-Mailbox -Identity "Myuser" -SearchQuery 'Subject:"project details"' -DeleteContent
 Note: you can add the delete content at the end to delete all the searched content.

Please find the some key list of AOS search.
To Restrict by File Type:                Use                                        Example
All file types                                 everything                          kind:everything
Communications                           communications                 kind:communications
Contacts                                      contacts                               kind:contacts
E-mail                                         email                                     kind:email
Instant Messenger                        conversations im                    kind:im
Meetings                                      meetings                             kind:meetings
Tasks                                           tasks                                      kind:tasks
Notes                                           notes                                    kind:notes
Documents                                   docs                                       kind:docs
Text documents                            text                                        kind:text
Spreadsheets                               spreadsheets                    kind:spreadsheets
Presentations                               presentations                    kind:presentations
Music                                          music                                    kind:music
Pictures                                       pics                                        kind:pics
Videos                                         videos                                   kind:videos
Folders                                        folders                                  kind:folders
Folder name                                 foldername or in              foldername:mydocs or in:mydocs
Favorites                                      favorites                              kind:favorites

Programs                                     programs                             kind:programs