Created
November 20, 2018 18:21
-
-
Save markroloff/87d69dde2ff03fd358bb97bafd8bbb92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Recover-LogSpace { | |
[CmdletBinding()] | |
Param( | |
[parameter(ValueFromPipelineByPropertyName, | |
Mandatory)] | |
[string[]] | |
$SqlServer, | |
[parameter(ValueFromPipelineByPropertyName)] | |
[string[]] | |
$Database | |
) | |
process { | |
"Working on $SqlServer" | |
if ($Database) { | |
"Connecting to $Database" | |
} else { | |
"Connecting to all databases" | |
} | |
} | |
} | |
[PSCustomObject]@{ | |
SqlServer = "sqlserver1\instance" | |
}, | |
[PSCustomObject]@{ | |
SqlServer = "sqlserver2\instance" | |
} | Recover-LogSpace | |
[PSCustomObject]@{ | |
SqlServer = "sqlserver1\instance" | |
Database = "database1" | |
}, | |
[PSCustomObject]@{ | |
SqlServer = "sqlserver2\instance" | |
Database = "database2" | |
} | Recover-LogSpace | |
### Output | |
Working on sqlserver1\instance | |
Connecting to all databases | |
Working on sqlserver2\instance | |
Connecting to all databases | |
Working on sqlserver1\instance | |
Connecting to database1 | |
Working on sqlserver2\instance | |
Connecting to database2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment