Skip to content

Commit 74cdd1e

Browse files
committed
update Azure resources
1 parent fa3a05d commit 74cdd1e

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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 New-MonkeyDiagnosticSettingObject {
16+
<#
17+
.SYNOPSIS
18+
Create a new diagnostic setting object
19+
20+
.DESCRIPTION
21+
Create a new diagnostic setting object
22+
23+
.INPUTS
24+
25+
.OUTPUTS
26+
27+
.EXAMPLE
28+
29+
.NOTES
30+
Author : Juan Garrido
31+
Twitter : @tr1ana
32+
File Name : New-MonkeyDiagnosticSettingObject
33+
Version : 1.0
34+
35+
.LINK
36+
https://github.com/silverhack/monkey365
37+
#>
38+
39+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Scope="Function")]
40+
[CmdletBinding()]
41+
Param (
42+
[parameter(Mandatory= $false, ValueFromPipeline = $True, HelpMessage="diagnostic setting object")]
43+
[AllowNull()]
44+
[Object]$InputObject
45+
)
46+
Process{
47+
try{
48+
#Create ordered dictionary
49+
$diagObj = [ordered]@{
50+
id = $null;
51+
name = $null;
52+
type = $null;
53+
properties = $null;
54+
enabled = $false;
55+
rawObject = $null;
56+
}
57+
If(($null -ne $InputObject) -and (($InputObject | Select-Object -ExpandProperty type -ErrorAction Ignore) -match "Microsoft.Insights/diagnosticSettings")){
58+
$diagObj.id = $InputObject | Select-Object -ExpandProperty id -ErrorAction Ignore;
59+
$diagObj.name = $InputObject | Select-Object -ExpandProperty name -ErrorAction Ignore;
60+
$diagObj.type = $InputObject | Select-Object -ExpandProperty type -ErrorAction Ignore;
61+
$diagObj.properties = $InputObject | Select-Object -ExpandProperty properties -ErrorAction Ignore;
62+
$diagObj.enabled = $True;
63+
$diagObj.rawObject = $InputObject;
64+
}
65+
#Create PsObject
66+
$_obj = New-Object -TypeName PsObject -Property $diagObj
67+
#return object
68+
return $_obj
69+
}
70+
catch{
71+
$msg = @{
72+
MessageData = ($message.MonkeyObjectCreationFailed -f "Diagnostic Setting");
73+
callStack = (Get-PSCallStack | Select-Object -First 1);
74+
logLevel = 'error';
75+
InformationAction = $O365Object.InformationAction;
76+
Tags = @('DiagnosticSettingObjectError');
77+
}
78+
Write-Error @msg
79+
$msg.MessageData = $_
80+
$msg.LogLevel = "Verbose"
81+
$msg.Tags+= "DiagnosticSettingObjectError"
82+
[void]$msg.Add('verbose',$O365Object.verbose)
83+
Write-Verbose @msg
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)