Skip to content

Commit 9477141

Browse files
committed
update Azure resources
1 parent 37514bc commit 9477141

2 files changed

Lines changed: 142 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Monkey365 - the PowerShell Cloud Security Tool for Azure and Microsoft 365 (copyright 2022) by Juan Garrido
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
Function Get-MonkeyAzDiagnosticSettingForResource {
16+
<#
17+
.SYNOPSIS
18+
Get diagnostic settings by resource
19+
20+
.DESCRIPTION
21+
Get diagnostic settings by resource
22+
23+
.INPUTS
24+
25+
.OUTPUTS
26+
27+
.EXAMPLE
28+
29+
.NOTES
30+
Author : Juan Garrido
31+
Twitter : @tr1ana
32+
File Name : Get-MonkeyAzDiagnosticSettingForResource
33+
Version : 1.0
34+
35+
.LINK
36+
https://github.com/silverhack/monkey365
37+
#>
38+
39+
[CmdletBinding()]
40+
Param (
41+
[Parameter(Mandatory=$True, ValueFromPipeline = $True, HelpMessage= 'Azure Object')]
42+
[Object]$InputObject,
43+
44+
[parameter(Mandatory=$false, HelpMessage="Attach to object")]
45+
[Switch]$AddToObject,
46+
47+
[parameter(Mandatory=$false, HelpMessage="API version")]
48+
[String]$APIVersion = "2021-05-01-preview"
49+
)
50+
Process{
51+
try{
52+
$diagObj = $null;
53+
$Id = $InputObject | Select-Object -ExpandProperty id -ErrorAction Ignore
54+
If($null -ne $Id){
55+
$p = @{
56+
Id = $Id;
57+
Resource = 'providers/microsoft.insights/diagnosticSettings';
58+
ApiVersion = $APIVersion;
59+
Verbose = $O365Object.verbose;
60+
Debug = $O365Object.debug;
61+
InformationAction = $O365Object.InformationAction;
62+
}
63+
$_diag = Get-MonkeyAzObjectById @p
64+
#Format object
65+
$_diag = New-MonkeyDiagnosticSettingObject -InputObject $_diag
66+
If($AddToObject.IsPresent){
67+
$InputObject | Add-Member -MemberType NoteProperty -Name diagnosticSettings -Value $_diag -Force
68+
return $InputObject
69+
}
70+
Else{
71+
return $_diag
72+
}
73+
}
74+
}
75+
catch{
76+
Write-Verbose $_
77+
}
78+
}
79+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Monkey365 - the PowerShell Cloud Security Tool for Azure and Microsoft 365 (copyright 2022) by Juan Garrido
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
Function Get-MonkeyAzDiagnosticSettingsById {
16+
<#
17+
.SYNOPSIS
18+
Get diagnostic settings by resource Id
19+
20+
.DESCRIPTION
21+
Get diagnostic settings by resource Id
22+
23+
.INPUTS
24+
25+
.OUTPUTS
26+
27+
.EXAMPLE
28+
29+
.NOTES
30+
Author : Juan Garrido
31+
Twitter : @tr1ana
32+
File Name : Get-MonkeyAzDiagnosticSettingsById
33+
Version : 1.0
34+
35+
.LINK
36+
https://github.com/silverhack/monkey365
37+
#>
38+
39+
[CmdletBinding()]
40+
Param (
41+
[Parameter(Mandatory=$True, ValueFromPipeline = $True, HelpMessage= 'Resource Id')]
42+
[Object]$Id,
43+
44+
[parameter(Mandatory=$false, HelpMessage="API version")]
45+
[String]$APIVersion = "2021-05-01-preview"
46+
)
47+
Process{
48+
try{
49+
$p = @{
50+
Id = $Id;
51+
Resource = 'providers/microsoft.insights/diagnosticSettings';
52+
ApiVersion = $APIVersion;
53+
Verbose = $O365Object.verbose;
54+
Debug = $O365Object.debug;
55+
InformationAction = $O365Object.InformationAction;
56+
}
57+
Get-MonkeyAzObjectById @p
58+
}
59+
catch{
60+
Write-Verbose $_
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)