Office 365 PowerShell

Running PowerShell for Office 365 allows you to tweak additional settings for cloud based accounts. There are several pre-requisites that need to occur prior to running Office 365 PowerShell commands / cmdlets. You will need to install the Microsoft Online PowerShell module from Microsoft. More information on how to install and configure Windows PowerShell can be found here. Once you have installed the module, run the following: Import-module msonline $LiveCred=Get-Credential Connect-MsolService –Credential $LiveCred Run the following 3 commands to connect Windows PowerShell to the Office 365 exchange service: $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ –Credential $LiveCred -Authentication Basic –AllowRedirection…

Copy NTFS permissions only and no data from source to target

This is how a colleague (John) and I at work managed to copy only permissions for files from a source to target folder. Each directory containing the exact same files. What happened, somebody copied the files to a new location but didn’t copy permissions at the same time, so we did this step at the end as a final step instead. At first we spent several long hours using Ropycopy, but this didn’t work and we eventually gave up. We tried the following robocopy commands: robocopy "\\<servername>\OLD_Information\T-E-S-T" “\\<servername>\Information\T-E-S-T” /e /secfix /copyall /xo /xn /xc /r:2 /w:1 /LOG+:c:\Log1.log /TEE robocopy "\\<servername>\OLD_Information\T-E-S-T"…

Connect to SMB2 Windows (CIFS) shares

From a Windows Server 2012 or Windows 8 machine, you might get the following message when connecting to an SMB2 share or network location. <server> is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions. An unexpected network error occurred. You need to update the server or SAN where the shares are hosted, alternatively run the following PowerShell command on the machine where you’re connecting from: Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" RequireSecureNegotiate -Value 0 -Force Be sure to run PowerShell as administrator if user account…

Get Exchange 2010 mailbox size which includes the dumpster

The following commands are examples to get mailbox sizes for users mailboxes per Exchange database. This gives you both the actual mailbox size and the dumpster (Soft-Deleted) items, items which have been shift-deleted from any folders, or deleted from Outlook’s deleted items folder. To get a list of all users mailbox sizes per database in descending order, run the following command: Get-MailboxStatistics –database <DataBase> | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},@{label="TotalDeletedItemSize(MB)";expression={$_.totaldeleteditemsize.Value.ToMB()}},ItemCount I refer to this link, it talks about the TotalDeletedItemSize, this refers to the email sitting in the dumpster which is accessible from the users perspective using Outlook’s Recover…

Grant full mailbox access to an Exchange 2010 mailbox without Auto mapping the mailbox

Some examples below is granting full mailbox permissions to users without the auto mapping feature. Run the following command to grant full mailbox access to a single mailbox: Add-MailboxPermission –Identity <mailbox> –User <user> -AccessRights FullAccess -InheritanceType all -Automapping $false Or, to give a user access full access permissions to all mailboxes, run: Get-Mailbox | Add-MailboxPermission –User <user> -AccessRights FullAccess -InheritanceType all -Automapping $false  

Adding/Changing Windows Registry values using PowerShell

You can use PowerShell to change registry values in Windows. Below, I give a few different examples of how to use the cmdlet in varies scenarios. From the Microsoft knowledge base article http://support.microsoft.com/kb/154596 How to configure RPC dynamic port allocation to work with firewalls, below is the PowerShell way, using 4 separate PowerShell cmdlets in the same order: New-Item -Path HKLM:\Software\Microsoft\Rpc\Internet New-ItemProperty -Path HKLM:\Software\Microsoft\Rpc\Internet -Name Ports -PropertyType MultiString -Value 5984-5994 New-ItemProperty -Path HKLM:\Software\Microsoft\Rpc\Internet -Name PortsInternetAvailable -PropertyType String -Value Y New-ItemProperty -Path HKLM:\Software\Microsoft\Rpc\Internet -Name UseInternetPorts -PropertyType String -Value Y To disable IPv6, run the following cmdlet: New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters -Name DisabledComponents…