Skip to content

Commit 346b6da

Browse files
committed
Add Azure resources
1 parent f3f5607 commit 346b6da

15 files changed

Lines changed: 625 additions & 265 deletions

core/api/azure/resourcemanagement/utils/New-MonkeyDiskObject.ps1 renamed to core/api/azure/resourcemanagement/helpers/disks/New-MonkeyDiskObject.ps1

File renamed without changes.

core/api/azure/resourcemanagement/helpers/virtualMachine/Get-MonkeyAzVMAVInfo.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Function Get-MonkeyAzVMAVInfo {
3737
#>
3838
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Scope="Function")]
3939
[CmdletBinding()]
40+
[OutputType([System.Boolean])]
4041
Param (
4142
[Parameter(Mandatory=$True, ValueFromPipeline = $True, HelpMessage="VM object")]
4243
[Object]$InputObject
@@ -45,11 +46,11 @@ Function Get-MonkeyAzVMAVInfo {
4546
try{
4647
If($null -ne $InputObject.PsObject.Properties.Item('resources') -and $null -ne $InputObject.resources){
4748
$av = @($InputObject.resources).Where({($_.Id -match "IaaSAntimalware" -or $_.Id -match "MDE.Windows" -or $_.Id -match "MDE.Linux") -and ($_.properties.provisioningState -ne 'Failed')})
48-
if($av.Count -gt 0){
49-
$InputObject.isAVAgentInstalled = $True
49+
If($av.Count -gt 0){
50+
return $True
5051
}
51-
else{
52-
$InputObject.isAVAgentInstalled = $false
52+
Else{
53+
return $false
5354
}
5455
}
5556
}

core/api/azure/resourcemanagement/helpers/virtualMachine/Get-MonkeyAzVMOMSInfo.ps1

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,34 @@ Function Get-MonkeyAzVMOMSInfo {
3737
#>
3838
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Scope="Function")]
3939
[CmdletBinding()]
40+
[OutputType([System.Boolean])]
4041
Param (
4142
[Parameter(Mandatory=$True, ValueFromPipeline = $True, HelpMessage="VM object")]
42-
[Object]$InputObject
43+
[Object]$InputObject,
44+
45+
[Parameter(Mandatory=$false, HelpMessage="Check for legacy OMS")]
46+
[Switch]$Legacy
4347
)
4448
Process{
4549
try{
4650
If($null -ne $InputObject.PsObject.Properties.Item('resources') -and $null -ne $InputObject.resources){
47-
$agent = @($vmObject.resources).Where({$_.Id -match "MicrosoftMonitoringAgent" -or $_.Id -match "OmsAgentForLinux"})
48-
if($agent.Count -gt 0){
49-
$InputObject.isVMAgentInstalled = $True
51+
If($PSBoundParameters.ContainsKey('Legacy') -and $PSBoundParameters['Legacy'].IsPresent){
52+
$agent = @($InputObject.resources).Where({$_.name -match "MicrosoftMonitoringAgent" -or $_.name -match "OmsAgentForLinux"})
53+
If($agent.Count -gt 0){
54+
return $True
55+
}
56+
Else{
57+
return $false
58+
}
5059
}
51-
else{
52-
$InputObject.isVMAgentInstalled = $false
60+
Else{
61+
$agent = @($InputObject.resources).Where({$_.name -match "AzureMonitorAgent"})
62+
If($agent.Count -gt 0){
63+
return $True
64+
}
65+
Else{
66+
return $false
67+
}
5368
}
5469
}
5570
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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-MonkeyAzVMRestorePoint {
16+
<#
17+
.SYNOPSIS
18+
Get Azure VM restore point
19+
20+
.DESCRIPTION
21+
Get Azure VM restore point
22+
23+
24+
.INPUTS
25+
26+
.OUTPUTS
27+
28+
.EXAMPLE
29+
30+
.NOTES
31+
Author : Juan Garrido
32+
Twitter : @tr1ana
33+
File Name : Get-MonkeyAzVMRestorePoint
34+
Version : 1.0
35+
36+
.LINK
37+
https://github.com/silverhack/monkey365
38+
#>
39+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Scope="Function")]
40+
[CmdletBinding()]
41+
Param (
42+
[Parameter(Mandatory=$True, ValueFromPipeline = $True, HelpMessage="VM object")]
43+
[Object]$InputObject,
44+
45+
[parameter(Mandatory=$false, HelpMessage="API version")]
46+
[String]$APIVersion = '2021-03-01'
47+
)
48+
Process{
49+
Try{
50+
#Set array
51+
$restorePoints = [System.Collections.Generic.List[System.Object]]::new()
52+
$q = ('resources\n| where type =~ \"microsoft.compute/restorepointcollections\"\n | where properties.source.id =~ \"{0}\"\n| project id,\nlocation,\nname,\ntype,\nproperties' -f $InputObject.id);
53+
$data = @{
54+
subscriptions = @($O365Object.auth_tokens.ResourceManager.SubscriptionId);
55+
query = $q;
56+
} | ConvertTo-Json -Depth 10 -Compress | ForEach-Object { [System.Text.RegularExpressions.Regex]::Unescape($_) }
57+
58+
$p = @{
59+
Resource = '/providers/Microsoft.ResourceGraph/resources';
60+
Method = 'POST';
61+
Data = $data;
62+
ApiVersion = $APIVersion;
63+
Verbose = $O365Object.verbose;
64+
Debug = $O365Object.debug;
65+
InformationAction = $O365Object.InformationAction;
66+
}
67+
$response = Get-MonkeyAzObjectById @p
68+
If($null -ne $response -and $response.Count -gt 0){
69+
ForEach($rp in $response.data){
70+
[void]$restorePoints.Add($rp);
71+
}
72+
}
73+
#return Object
74+
Write-Output $restorePoints -NoEnumerate
75+
}
76+
Catch{
77+
Write-Verbose $_
78+
}
79+
}
80+
}

core/api/azure/resourcemanagement/helpers/virtualMachine/Get-MonkeyAzVMScaleSetInfo.ps1

Lines changed: 0 additions & 200 deletions
This file was deleted.

0 commit comments

Comments
 (0)