Skip to content

Commit 1ec3a30

Browse files
author
haraldpfirmann
committed
Scripts reviewed
1 parent c5026de commit 1ec3a30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+129
-189
lines changed

DBSystems/SQLServer/Get-DMSSQLAgent.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,19 @@ Param(
4242
[string]$ServerInstance,
4343
[pscredential]$ServerCredential,
4444
[int]$ConnectionTimeout = 30,
45-
[string]$Properties = "Name,State,AgentLogLevel,ErrorLogFile,MaximumHistoryRows,ServiceAccount,ServiceStartMode,SqlAgentAutoStart"
45+
[Validateset('*','Name','State','AgentLogLevel','ErrorLogFile','MaximumHistoryRows','ServiceAccount','ServiceStartMode','SqlAgentAutoStart')]
46+
[string[]]$Properties = @('Name','State','AgentLogLevel','ErrorLogFile','MaximumHistoryRows','ServiceAccount','ServiceStartMode','SqlAgentAutoStart')
4647
)
4748

4849
Import-Module SQLServer
4950

5051
try{
51-
if([System.String]::IsNullOrWhiteSpace($Properties)){
52-
$Properties = '*'
53-
}
5452
$instance = GetSQLServerInstance -ServerInstance $ServerInstance -ServerCredential $ServerCredential -ConnectionTimeout $ConnectionTimeout
5553

5654
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
5755
'InputObject' = $instance
5856
}
59-
$result = Get-SqlAgent @cmdArgs | Select-Object $Properties.Split(',')
57+
$result = Get-SqlAgent @cmdArgs | Select-Object $Properties
6058

6159
if($SRXEnv) {
6260
$SRXEnv.ResultMessage = $result

DBSystems/SQLServer/Get-DMSSQLAgentJob.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,20 @@ Param(
4646
[pscredential]$ServerCredential,
4747
[string]$JobName,
4848
[int]$ConnectionTimeout = 30,
49-
[string]$Properties = "Name,State,LastRunDuration,CurrentRunStatus,DateLastModified,Description,EmailLevel,EventLogLevel,OwnerLoginName"
49+
[Validateset('*','Name','State','LastRunDuration','CurrentRunStatus','DateLastModified','Description','EmailLevel','EventLogLevel','OwnerLoginName')]
50+
[string[]]$Properties = @('Name','State','LastRunDuration','CurrentRunStatus','DateLastModified','Description','EmailLevel','EventLogLevel','OwnerLoginName')
5051
)
5152

5253
Import-Module SQLServer
5354

5455
try{
55-
if([System.String]::IsNullOrWhiteSpace($Properties)){
56-
$Properties = '*'
57-
}
5856
$instance = GetSQLServerInstance -ServerInstance $ServerInstance -ServerCredential $ServerCredential -ConnectionTimeout $ConnectionTimeout
5957

6058
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'}
6159
if([System.String]::IsNullOrWhiteSpace($JobName) -eq $false){
6260
$cmdArgs.Add('Name',$JobName)
6361
}
64-
$result = Get-SqlAgent -InputObject $instance -ErrorAction Stop | Get-SqlAgentJob @cmdArgs | Select-Object $Properties.Split(',')
62+
$result = Get-SqlAgent -InputObject $instance -ErrorAction Stop | Get-SqlAgentJob @cmdArgs | Select-Object $Properties
6563

6664
if($SRXEnv) {
6765
$SRXEnv.ResultMessage = $result

DBSystems/SQLServer/Get-DMSSQLAgentJobHistory.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@
5555
5656
.Parameter ConnectionTimeout
5757
Specifies the time period to retry the command on the target server
58-
59-
.Parameter Properties
60-
List of properties to expand, comma separated e.g. Name,State. Use * for all properties
6158
#>
6259

6360
[CmdLetBinding()]

DBSystems/SQLServer/Get-DMSSQLAgentJobSchedule.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,13 @@ Param(
5050
[string]$JobName,
5151
[string]$ScheduleName,
5252
[int]$ConnectionTimeout = 30,
53-
[string]$Properties = "Name,ID,State,ActiveStartDate,ActiveEndDate,DateCreated,FrequencyTypes,IsEnabled,JobCount"
53+
[ValidateSet('*','Name','ID','State','ActiveStartDate','ActiveEndDate','DateCreated','FrequencyTypes','IsEnabled','JobCount')]
54+
[string[]]$Properties = @('Name','ID','State','ActiveStartDate','ActiveEndDate','DateCreated','FrequencyTypes','IsEnabled','JobCount')
5455
)
5556

5657
Import-Module SQLServer
5758

5859
try{
59-
if([System.String]::IsNullOrWhiteSpace($Properties)){
60-
$Properties = '*'
61-
}
6260
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
6361
'ServerInstance' = $ServerInstance
6462
'ConnectionTimeout' = $ConnectionTimeout
@@ -76,7 +74,7 @@ try{
7674
$cmdSchedule.Add('Name',$ScheduleName)
7775
}
7876
$result = Get-SqlAgent @cmdArgs | Get-SqlAgentJob @cmdJob `
79-
| Get-SqlAgentJobSchedule @cmdSchedule | Select-Object $Properties.Split(',')
77+
| Get-SqlAgentJobSchedule @cmdSchedule | Select-Object $Properties
8078

8179
if($SRXEnv) {
8280
$SRXEnv.ResultMessage = $result

DBSystems/SQLServer/Get-DMSSQLAgentJobStep.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,13 @@ Param(
5050
[string]$JobName,
5151
[string]$StepName,
5252
[int]$ConnectionTimeout = 30,
53-
[string]$Properties = "Name,ID,State,Command,LastRunDate,LastRunDuration,LastRunDurationAsTimeSpan,OnFailAction,OnSuccessAction"
53+
[ValidateSet('*','Name','ID','State','Command','LastRunDate','LastRunDuration','LastRunDurationAsTimeSpan','OnFailAction','OnSuccessAction')]
54+
[string[]]$Properties = @('Name','ID','State','Command','LastRunDate','LastRunDuration','LastRunDurationAsTimeSpan','OnFailAction','OnSuccessAction')
5455
)
5556

5657
Import-Module SQLServer
5758

5859
try{
59-
if([System.String]::IsNullOrWhiteSpace($Properties)){
60-
$Properties = '*'
61-
}
6260
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
6361
'ServerInstance' = $ServerInstance
6462
'ConnectionTimeout' = $ConnectionTimeout
@@ -76,7 +74,7 @@ try{
7674
$cmdStep.Add('Name',$StepName)
7775
}
7876
$result = Get-SqlAgent @cmdArgs | Get-SqlAgentJob @cmdJob `
79-
| Get-SqlAgentJobStep @cmdStep | Select-Object $Properties.Split(',')
77+
| Get-SqlAgentJobStep @cmdStep | Select-Object $Properties
8078

8179
if($SRXEnv) {
8280
$SRXEnv.ResultMessage = $result

DBSystems/SQLServer/Get-DMSSQLAgentSchedule.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ Param(
4646
[pscredential]$ServerCredential,
4747
[string]$ScheduleName,
4848
[int]$ConnectionTimeout = 30,
49-
[string]$Properties = "Name,ID,State,ActiveStartDate,ActiveEndDate,DateCreated,FrequencyTypes,IsEnabled,JobCount"
49+
[ValidateSet('*','Name','ID','State','ActiveStartDate','ActiveEndDate','DateCreated','FrequencyTypes','IsEnabled','JobCount')]
50+
[string[]]$Properties = @('Name','ID','State','ActiveStartDate','ActiveEndDate','DateCreated','FrequencyTypes','IsEnabled','JobCount')
5051
)
5152

5253
Import-Module SQLServer
5354

5455
try{
55-
if([System.String]::IsNullOrWhiteSpace($Properties)){
56-
$Properties = '*'
57-
}
5856
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
5957
'ServerInstance' = $ServerInstance
6058
'ConnectionTimeout' = $ConnectionTimeout
@@ -67,7 +65,7 @@ try{
6765
if([System.String]::IsNullOrWhiteSpace($ScheduleName) -eq $false){
6866
$cmdSchedule.Add('Name',$ScheduleName)
6967
}
70-
$result = Get-SqlAgent @cmdArgs | Get-SqlAgentSchedule @cmdSchedule | Select-Object $Properties.Split(',')
68+
$result = Get-SqlAgent @cmdArgs | Get-SqlAgentSchedule @cmdSchedule | Select-Object $Properties
7169

7270
if($SRXEnv) {
7371
$SRXEnv.ResultMessage = $result

DBSystems/SQLServer/Get-DMSSQLBackupHistory.ps1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,13 @@ Param(
7373
[ValidateSet('Midnight', 'Yesterday', 'LastWeek', 'LastMonth')]
7474
[string]$Since,
7575
[int]$ConnectionTimeout = 30,
76-
[string]$Properties = "Name,Status,Size,SpaceAvailable,Owner,LastBackupDate,LastLogBackupDate,IsUpdateable,DefaultFileGroup,AutoShrink,ActiveConnections"
76+
[ValidateSet('*','Name','Status','Size','SpaceAvailable','Owner','LastBackupDate','LastLogBackupDate','IsUpdateable','DefaultFileGroup','AutoShrink','ActiveConnections')]
77+
[string[]]$Properties = @('Name','Status','Size','SpaceAvailable','Owner','LastBackupDate','LastLogBackupDate','IsUpdateable','DefaultFileGroup','AutoShrink','ActiveConnections')
7778
)
7879

7980
Import-Module SQLServer
8081

8182
try{
82-
if([System.String]::IsNullOrWhiteSpace($Properties)){
83-
$Properties='*'
84-
}
8583
$instance = GetSQLServerInstance -ServerInstance $ServerInstance -ServerCredential $ServerCredential -ConnectionTimeout $ConnectionTimeout
8684

8785
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
@@ -106,13 +104,13 @@ try{
106104
$cmdArgs.Add("Since",$Since)
107105
}
108106

109-
$Script:result = Get-SqlBackupHistory @cmdArgs | Select-Object *
107+
$result = Get-SqlBackupHistory @cmdArgs | Select-Object $Properties
110108

111109
if($SRXEnv) {
112-
$SRXEnv.ResultMessage = $Script:result
110+
$SRXEnv.ResultMessage = $result
113111
}
114112
else{
115-
Write-Output $Script:result
113+
Write-Output $result
116114
}
117115
}
118116
catch{

DBSystems/SQLServer/Get-DMSSQLColumnEncryptionKey.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ try{
6363
$cmdArgs.Add("Name",$KeyName)
6464
}
6565

66-
$Script:result = Get-SqlColumnEncryptionKey @cmdArgs | Select-Object *
66+
$result = Get-SqlColumnEncryptionKey @cmdArgs | Select-Object *
6767

6868
if($SRXEnv) {
69-
$SRXEnv.ResultMessage = $Script:result
69+
$SRXEnv.ResultMessage = $result
7070
}
7171
else{
72-
Write-Output $Script:result
72+
Write-Output $result
7373
}
7474
}
7575
catch{

DBSystems/SQLServer/Get-DMSSQLColumnMasterKey.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ try{
6363
$cmdArgs.Add("Name",$KeyName)
6464
}
6565

66-
$Script:result = Get-SqlColumnMasterKey @cmdArgs | Select-Object *
66+
$result = Get-SqlColumnMasterKey @cmdArgs | Select-Object *
6767
if($SRXEnv) {
68-
$SRXEnv.ResultMessage = $Script:result
68+
$SRXEnv.ResultMessage = $result
6969
}
7070
else{
71-
Write-Output $Script:result
71+
Write-Output $result
7272
}
7373
}
7474
catch{

DBSystems/SQLServer/Get-DMSSQLCredential.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ try{
5656
'Name' = $Name
5757
'Confirm' = $false
5858
}
59-
$Script:result = Get-SqlCredential @cmdArgs | Select-Object *
59+
$result = Get-SqlCredential @cmdArgs | Select-Object *
6060

6161
if($SRXEnv) {
62-
$SRXEnv.ResultMessage = $Script:result
62+
$SRXEnv.ResultMessage = $result
6363
}
6464
else{
65-
Write-Output $Script:result
65+
Write-Output $result
6666
}
6767
}
6868
catch{

0 commit comments

Comments
 (0)