Thursday, May 31, 2018

Exchange change Search results limit 250

Exchange 2016  has search limit , when your outlook is online, or in web mail
to change this limit run this command in exchange shell to change limit from 250 to 5000:


New-SettingOverride -Name "Increase Search Results Limit" -Component ManagedStore -Section StoreSettings -Parameters @("MaxHitsForFullTextIndexSearches=5000") -Reason "Increases Search Result Limit from 250 to 5000"

Wednesday, May 30, 2018

Export File server Permissions to CSV

Export share folder Permissions to CSV file using powershell:


 $FolderPath = dir -Directory -Path "\\sharefolderPath" -Recurse -Force
 $Report = @()
 Foreach ($Folder in $FolderPath) {
     $Acl = Get-Acl -Path $Folder.FullName
     foreach ($Access in $acl.Access)
         {
             $Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
 Group or
 User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
             $Report += New-Object -TypeName PSObject -Property $Properties
         }
 }
 $Report | Export-Csv -path "C:\tmp\FolderPermissions.csv"

Export mailbox usage space from Organization unit


Get-Mailbox -DomainController dc01.test.local -OrganizationalUnit "test.local/test/"  -resultsize unlimited | Get-MailboxStatistics  | Sort-Object TotalItemSize -Descending | convertto-html DisplayName, @{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}} | set-content c:\tmp\log.html

Force clean up deleted mailboxes in Exchange Database

To view free space in exchange database use this command:

Get-MailboxDatabase -Status | select Name,DatabaseSize,AvailableNewMailboxSpace

When you disable mailbox from ECP, default exchange removes it in 30 days,
if you do not have free space and you want to do delete it force use this commands :

Get-MailboxDatabase | Get-MailboxStatistics | Where { $_.DisplayName -eq "disabled mailbox Displayname" } | fl DisplayName,MailboxGuid,Database,DisconnectReason

you will see: something like this:

DisplayName      : Test User
MailboxGuid      : 07f47962-3963-44f1-9974-c298cd7bd6f8
Database         :  MBX01

DisconnectReason :

to completely remove :

Remove-StoreMailbox -Database Cloud-MBX-Custom-1 -Identity "disabled mailbox guid" - MailboxState Disabled

In several minutes free space will added to Datatabase.


Wednesday, May 23, 2018

System Center Service Manager HTML email notification

When you are using  HTML template, now the formatting is stripped; cause a line break should be written as <br /> and not with the enter key on the keyboard.
The solution to this is to use <pre>

Just add to your incident description in html:
<pre>$Context/Property[Type='WorkItem!System.WorkItem']/Description$</pre>

Source

System Center Service Manager delete the items and reset

After Installing new Service Manager server to delete test incidents, and reset IR number follow this instruction: 

Install the SMLets database on the SCSM server, 
open the Powershell  to removal of Incident events:
Import-Module SMLets
Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.Incident$) | Remove-SCSMObject -Force -Confirm

Login to the Service Manager database (SQL Server):
select * from AutoIncrementAvailableRange

Select MT.TypeName,MT.ManagedTypeId,MTP.ManagedTypePropertyName,MTP.ManagedTypePropertyID,AIAR.FirstAvailableValue
from ManagedType as MT, ManagedTypeProperty as MTP, AutoIncrementAvailableRange as AIAR
where MT.ManagedTypeId = AIAR.ManagedTypeId and MTP.ManagedTypePropertyId = AIAR.ManagedTypePropertyId

All project number, is according to the table in the last line of data coding, that is to say, if you want to make Incident ID digital restart from the beginning of 1, change:

update AutoIncrementAvailableRange
set FirstAvailableValue = 1 
where ManagedTypeId = 'F59821E2-0364-ED2C-19E3-752EFBB1ECE9' and ManagedTypePropertyId = '28B1C58F-AEFA-A449-7496-4805186BD94F'

*If youare using Datawarehouse  Server , to reset reports, most easy way is to unregister dataworhouse server and install new  server.



Monday, May 21, 2018

Remove Incident SCSM


To remove for example IR10:

Import-Module SMLets

Get-SCSMClassInstance -Class (Get-SCSMClass -Name System.WorkItem.Incident) | Where-Object {$_.ID -eq "IR10"} | Remove-SCSMClassInstance

Reset password to all users in OU


Get-ADUser -Filter * -SearchScope Subtree -SearchBase "OU=Users,OU=test,DC=test,DC=local" -Server test.local|   Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "pass-123" -Force)