PowerShell – Check if “-verbose” is passed on command line.

Create a test to see if the command line had “-verbose” on it. Then run something.

if ($PSBoundParameters.verbose)	{
    Get-Item -Path "$OutputFile"
}

Here’s another way (found at StackOverflow.)

function DoStuff {
    [CmdletBinding()]
    param()

    process {
        if ($PSBoundParameters['Verbose']) {
            # do verbose stuff
        }

        New-Item Test -Type Directory -Verbose:($PSBoundParameters['Verbose'] -eq $true)
    }
}

PowerShell Setup

Signing PowerShell Scripts

1. Opening Windows PowerShell 1.0 gets this error
Windows PowerShell
Copyright (C) 2006 Microsoft Corporation. All rights reserved.
File \asdfWindowsPowerShellMicrosoft.PowerShell_profile.ps1 cannot be loaded because the execution
 of scripts is disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:2
+ . <<<< '\asdfWindowsPowerShellMicrosoft.PowerShell_profile.ps1'
PS L:>
PS L:> Get-ExecutionPolicy
Restricted
PS L:> Set-ExecutionPolicy remotesigned
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
PS L:>

 Process should have elevated status to access IIS configuration data.

Install 64-bit ACE.OLEDB Download Microsoft Access Database Engine 2010 with 32-bit Office

 

  1. Download Microsoft Access Database Engine 2010 Redistributable here
  2. Install the version you need. I have 32-bit Office and a 64-bit PC using Windows 7 so had to do this to avoid the error about uninstalling Office:
  3. AccessDatabaseEngine_X64.exe /passive
  4. And it worked!

EDIT:

But it also now creates a problem whenever an OFFICE document is opened. Here’s a solution, although I had to add the “NoReReg REG_DWORD 1” myself in HKCU\Software\Microsoft\Office\14.0\Word\Options
Microsoft Office 2010 Professional Plus configures each time you start 

PowerShell and why I will learn it.

Up until SQL Server 2008, I didn't need PowerShell to manage my dozen servers and know exactly what was going on. Now I do.

And the benefits and capabilities are plentiful! You can start to be convinced by reading this article, "Why This SQL Server DBA is Learning Powershell", brilliantly conceived.

Next, use this site as a resource and examples.

Here is a great set of examples by MAK.