Okay, so I'm building a script to migrate on-prem mailboxes to Office 365 and perform a lot of pre and post migration tasks. I wanted to make sure I don't make any changes while I'm troubleshooting the script, so I decided to look at implementing cmdlet binding so that I can pass in -Verbose and -Whatif, but it looks like the Whatif is bleeding into parts of my script that I always want to run regardless (like loading modules at the beginning). Is there a good way to toggle or exempt certain parts of the script without manually flipping the $Whatifpreference variable back and forth constantly? See the output below with some Whatifs bleeding into the Exchange 2010 snapin load:
PS C:\Powershell> .\Migrate-O365Office.ps1 -OfficeCode ZZ-ZZZ-1 -WhatIf
What if: Performing operation "Start-Transcript" on Target "C:\PowerShell\OfficeMigration\ZZ-ZZZ-1_2013-06-21--13-30-56.
log".
What if: Performing operation "Set Alias" on Target "Name: list Value: format-list".
What if: Performing operation "Set Alias" on Target "Name: table Value: format-table".
What if: Performing operation "Update TypeData" on Target "FileName: C:\Program Files\Microsoft\Exchange Server\V14\bin\
exchange.types.ps1xml".
What if: Performing operation "Update TypeData" on Target "FileName: C:\Program Files\Microsoft\Exchange Server\V14\bin\
Exchange.partial.Types.ps1xml".
Welcome to the Exchange Management Shell!
Full list of cmdlets: Get-Command
Only Exchange cmdlets: Get-ExCommand
Cmdlets that match a specific string: Help *<string>*
Any thoughts?