diff --git a/Activity_AddOrUpdateTableRows/function.json b/Activity_AddOrUpdateTableRows/function.json
new file mode 100644
index 000000000000..f87c62c534f8
--- /dev/null
+++ b/Activity_AddOrUpdateTableRows/function.json
@@ -0,0 +1,9 @@
+{
+ "bindings": [
+ {
+ "name": "TableParams",
+ "type": "activityTrigger",
+ "direction": "in"
+ }
+ ]
+}
diff --git a/Activity_AddOrUpdateTableRows/run.ps1 b/Activity_AddOrUpdateTableRows/run.ps1
new file mode 100644
index 000000000000..82c6e89a7988
--- /dev/null
+++ b/Activity_AddOrUpdateTableRows/run.ps1
@@ -0,0 +1,3 @@
+param($TableParams)
+
+Add-AzDataTableEntity @TableParams
diff --git a/Activity_GetAllTableRows/function.json b/Activity_GetAllTableRows/function.json
new file mode 100644
index 000000000000..ce320a44c1a3
--- /dev/null
+++ b/Activity_GetAllTableRows/function.json
@@ -0,0 +1,9 @@
+{
+ "bindings": [
+ {
+ "name": "name",
+ "type": "activityTrigger",
+ "direction": "in"
+ }
+ ]
+}
diff --git a/Activity_GetAllTableRows/run.ps1 b/Activity_GetAllTableRows/run.ps1
new file mode 100644
index 000000000000..77eae52833be
--- /dev/null
+++ b/Activity_GetAllTableRows/run.ps1
@@ -0,0 +1,6 @@
+param($name)
+
+$Table = Get-CippTable -tablename $name
+$Rows = Get-AzDataTableEntity @Table
+
+Write-Output $Rows
\ No newline at end of file
diff --git a/AddAPDevice/run.ps1 b/AddAPDevice/run.ps1
index 8b0642a64a3d..09218a57c4d6 100644
--- a/AddAPDevice/run.ps1
+++ b/AddAPDevice/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -23,12 +23,12 @@ $Result = try {
$NewStatus = New-GraphgetRequest -uri "https://api.partnercenter.microsoft.com/v1/customers/$tenantfilter/DeviceBatches" -scope 'https://api.partnercenter.microsoft.com/user_impersonation'
if ($Newstatus.totalcount -eq $CurrentStatus.totalcount) { throw "We could not find the new autopilot device. Please check if your input is correct." }
Write-Host $CurrentStatus.Items
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($Request.body.TenantFilter) -message "Created Autopilot devices group. Group ID is $GroupName" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($Request.body.TenantFilter) -message "Created Autopilot devices group. Group ID is $GroupName" -Sev "Info"
"Created Autopilot devices group for $($Request.body.TenantFilter). Group ID is $GroupName"
}
catch {
"$($Request.body.TenantFilter): Failed to create autopilot devices. $($_.Exception.Message)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($Request.body.TenantFilter) -message "Failed to create autopilot devices. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($Request.body.TenantFilter) -message "Failed to create autopilot devices. $($_.Exception.Message)" -Sev "Error"
}
$body = [pscustomobject]@{"Results" = $Result }
diff --git a/AddAlert/run.ps1 b/AddAlert/run.ps1
index 8db4446d852a..6d1f151d6fc5 100644
--- a/AddAlert/run.ps1
+++ b/AddAlert/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$Tenants = ($Request.body | Select-Object Select_*).psobject.properties.value
$Results = foreach ($Tenant in $tenants) {
@@ -29,22 +29,25 @@ $Results = foreach ($Tenant in $tenants) {
UnusedLicenses = [bool]$Request.body.UnusedLicenses
AppSecretExpiry = [bool]$Request.body.AppSecretExpiry
type = 'Alert'
+ RowKey = $TenantID
+ PartitionKey = 'Alert'
}
- $TableRow = @{
- table = (get-cipptable -TableName 'SchedulerConfig')
- rowKey = $TenantID
- partitionKey = 'Alert'
+ $Table = get-cipptable -TableName 'SchedulerConfig'
+ <#$TableRow = @{
+ table = ()
property = $CompleteObject
UpdateExisting = $true
- }
+ }#>
Write-Host ($TableRow | ConvertTo-Json)
- Add-AzTableRow @TableRow | Out-Null
+
+ #Add-AzTableRow @TableRow | Out-Null
+ Add-AzDataTableEntity @Table -Entity $CompleteObject -Force
"Succesfully added Alert for $($Tenant) to queue."
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Succesfully added Alert for $($Tenant) to queue." -Sev 'Info'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Succesfully added Alert for $($Tenant) to queue." -Sev 'Info'
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed to add Alert for for $($Tenant) to queue" -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed to add Alert for for $($Tenant) to queue" -Sev 'Error'
"Failed to add Alert for for $($Tenant) to queue $($_.Exception.message)"
}
}
diff --git a/AddAutopilotConfig/run.ps1 b/AddAutopilotConfig/run.ps1
index c9a60fa15c11..75f7d0dab173 100644
--- a/AddAutopilotConfig/run.ps1
+++ b/AddAutopilotConfig/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -43,17 +43,17 @@ $results = foreach ($Tenant in $tenants) {
}
$Body = ConvertTo-Json -InputObject $ObjBody
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles" -body $body -tenantid $Tenant
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Added Autopilot profile $($Displayname)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Added Autopilot profile $($Displayname)" -Sev "Info"
if ($AssignTo) {
$AssignBody = '{"target":{"@odata.type":"#microsoft.graph.allDevicesAssignmentTarget"}}'
$assign = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeploymentProfiles/$($GraphRequest.id)/assignments" -tenantid $Tenant -type POST -body $AssignBody
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Assigned autopilot profile $($Displayname) to $AssignTo" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Assigned autopilot profile $($Displayname) to $AssignTo" -Sev "Info"
}
"Succesfully added profile for $($Tenant)"
}
catch {
"Failed to add profile for $($Tenant): $($_.Exception.Message)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Failed adding Autopilot Profile $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Failed adding Autopilot Profile $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
continue
}
diff --git a/AddCAPolicy/run.ps1 b/AddCAPolicy/run.ps1
index a4781a83c6bc..f1f0cbb20d8d 100644
--- a/AddCAPolicy/run.ps1
+++ b/AddCAPolicy/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Tenants = ($Request.body | Select-Object Select_*).psobject.properties.value
if ("AllTenants" -in $Tenants) { $Tenants = (Get-Tenants).DefaultDomainName }
@@ -47,12 +47,12 @@ $results = foreach ($Tenant in $tenants) {
}
$CreateRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies" -tenantid $tenant -type POST -body $RawJSON
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Added Conditional Access Policy $($Displayname)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Added Conditional Access Policy $($Displayname)" -Sev "Error"
"Succesfully added Conditional Access Policy for $($Tenant)"
}
catch {
"Failed to add policy for $($Tenant): $($_.Exception.Message)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed adding Conditional Access Policy $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed adding Conditional Access Policy $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
continue
}
diff --git a/AddCATemplate/run.ps1 b/AddCATemplate/run.ps1
index 3fa93b7a2c56..73ea2f874227 100644
--- a/AddCATemplate/run.ps1
+++ b/AddCATemplate/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Write-Host ($request | ConvertTo-Json -Compress)
try {
@@ -21,12 +21,12 @@ try {
}
$JSON = ($JSON | ConvertTo-Json -Depth 10)
Set-Content "Config\$($GUID).CATemplate.json" -Value ($JSON) -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created Transport Rule Template $($Request.body.name) with GUID $GUID" -Sev "Debug"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created Transport Rule Template $($Request.body.name) with GUID $GUID" -Sev "Debug"
$body = [pscustomobject]@{"Results" = "Successfully added template" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to create Transport Rule Template: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to create Transport Rule Template: $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Intune Template Deployment failed: $($_.Exception.Message)" }
}
diff --git a/AddChocoApp/run.ps1 b/AddChocoApp/run.ps1
index 8948f5fd3469..99f8ca91a19e 100644
--- a/AddChocoApp/run.ps1
+++ b/AddChocoApp/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Write-Host "PowerShell HTTP trigger function processed a request."
@@ -34,10 +34,10 @@ $Results = foreach ($Tenant in $tenants) {
} | ConvertTo-Json -Depth 15
$JSONFile = New-Item -Path ".\ChocoApps.Cache\$((New-Guid).GUID)" -Value $CompleteObject -Force -ErrorAction Stop
"Succesfully added Choco App for $($Tenant) to queue."
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Chocolatey Application $($intunebody.Displayname) queued to add" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Chocolatey Application $($intunebody.Displayname) queued to add" -Sev "Info"
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed to add Chocolatey Application $($intunebody.Displayname) to queue" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed to add Chocolatey Application $($intunebody.Displayname) to queue" -Sev "Error"
"Failed added Choco App for $($Tenant) to queue"
}
}
diff --git a/AddChocoApp_OrchestrationStarter/run.ps1 b/AddChocoApp_OrchestrationStarter/run.ps1
index d0674a094599..2e0e65863d11 100644
--- a/AddChocoApp_OrchestrationStarter/run.ps1
+++ b/AddChocoApp_OrchestrationStarter/run.ps1
@@ -4,13 +4,13 @@ param($Request, $TriggerMetadata)
$CurrentlyRunning = Get-Item "ChocoApps.Cache\CurrentlyRunning.txt" -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{"Results" = "Already running. Please wait for the current instance to finish" }
- Log-request -API "ChocoApps" -message "Attempted to start upload but an instance was already running." -sev Info
+ Write-LogMessage -API "ChocoApps" -message "Attempted to start upload but an instance was already running." -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName 'Applications_Orchestrator'
Write-Host "Started orchestration with ID = '$InstanceId'"
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId
- Log-request -API "ChocoApps" -message "Started uploading applications to tenants" -sev Info
+ Write-LogMessage -API "ChocoApps" -message "Started uploading applications to tenants" -sev Info
$Results = [pscustomobject]@{"Results" = "Started application queue" }
}
Write-Host ($Orchestrator | ConvertTo-Json)
diff --git a/AddChocoApp_OrchestrationStarterTimer/run.ps1 b/AddChocoApp_OrchestrationStarterTimer/run.ps1
index ae2f2e89fd26..e106bf6dd587 100644
--- a/AddChocoApp_OrchestrationStarterTimer/run.ps1
+++ b/AddChocoApp_OrchestrationStarterTimer/run.ps1
@@ -4,13 +4,13 @@ try {
$CurrentlyRunning = Get-Item 'ChocoApps.Cache\CurrentlyRunning.txt' -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' }
- Log-request -API 'ChocoApps' -message 'Attempted to start upload but an instance was already running.' -sev Info
+ Write-LogMessage -API 'ChocoApps' -message 'Attempted to start upload but an instance was already running.' -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName 'Applications_Orchestrator'
Write-Host "Started orchestration with ID = '$InstanceId'"
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Timer -InstanceId $InstanceId
- Log-request -API 'ChocoApps' -message 'Started uploading applications to tenants' -sev Info
+ Write-LogMessage -API 'ChocoApps' -message 'Started uploading applications to tenants' -sev Info
$Results = [pscustomobject]@{'Results' = 'Started running analysis' }
}
Write-Host ($Orchestrator | ConvertTo-Json)
diff --git a/AddEnrollment/run.ps1 b/AddEnrollment/run.ps1
index 066dae2ac42f..a2da5dbfad9d 100644
--- a/AddEnrollment/run.ps1
+++ b/AddEnrollment/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -37,12 +37,12 @@ $results = foreach ($Tenant in $tenants) {
$ExistingStatusPage = (New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/deviceManagement/deviceEnrollmentConfigurations" -tenantid $Tenant) | Where-Object { $_.id -like "*DefaultWindows10EnrollmentCompletionPageConfiguration" }
$GraphRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/deviceEnrollmentConfigurations/$($ExistingStatusPage.ID)" -body $body -Type PATCH -tenantid $tenant
"Succesfully changed default enrollment status page for $($Tenant)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Added Autopilot Enrollment Status Page $($Displayname)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Added Autopilot Enrollment Status Page $($Displayname)" -Sev "Info"
}
catch {
"Failed to change default enrollment status page for $($Tenant): $($_.Exception.Message)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed adding Autopilot Enrollment Status Page $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Failed adding Autopilot Enrollment Status Page $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
continue
}
diff --git a/AddGroup/run.ps1 b/AddGroup/run.ps1
index 311376a4590b..3896f61086fb 100644
--- a/AddGroup/run.ps1
+++ b/AddGroup/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$groupobj = $Request.body
@@ -36,11 +36,11 @@ try {
New-ExoRequest -tenantid $groupobj.tenantid -cmdlet "New-DistributionGroup" -cmdParams $params
}
$body = [pscustomobject]@{"Results" = "Succesfully created group. $($_.Exception.Message)" }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($groupobj.tenantid) -message "Created group $($groupobj.displayname) with id $($GraphRequest.id) " -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($groupobj.tenantid) -message "Created group $($groupobj.displayname) with id $($GraphRequest.id) " -Sev "Info"
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($groupobj.tenantid) -message "Group creation API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($groupobj.tenantid) -message "Group creation API failed. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to create group. $($_.Exception.Message)" }
}
diff --git a/AddIntuneTemplate/run.ps1 b/AddIntuneTemplate/run.ps1
index 4c3018ee58e7..bf18bf71ee61 100644
--- a/AddIntuneTemplate/run.ps1
+++ b/AddIntuneTemplate/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$GUID = (New-Guid).GUID
try {
@@ -22,7 +22,7 @@ try {
} | ConvertTo-Json
New-Item Config -ItemType Directory -ErrorAction SilentlyContinue
Set-Content "Config\$($GUID).IntuneTemplate.json" -Value $Object -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created intune policy template named $($Request.body.displayname) with GUID $GUID" -Sev "Debug"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created intune policy template named $($Request.body.displayname) with GUID $GUID" -Sev "Debug"
$body = [pscustomobject]@{"Results" = "Successfully added template" }
}
@@ -71,13 +71,13 @@ try {
} | ConvertTo-Json
New-Item Config -ItemType Directory -ErrorAction SilentlyContinue
Set-Content "Config\$($GUID).IntuneTemplate.json" -Value $Object -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created intune policy template $($Request.body.displayname) with GUID $GUID using an original policy from a tenant" -Sev "Debug"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created intune policy template $($Request.body.displayname) with GUID $GUID using an original policy from a tenant" -Sev "Debug"
$body = [pscustomobject]@{"Results" = "Successfully added template" }
}
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Intune Template Deployment failed: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Intune Template Deployment failed: $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Intune Template Deployment failed: $($_.Exception.Message)" }
}
diff --git a/AddMSPApp/run.ps1 b/AddMSPApp/run.ps1
index d061819cee60..1a8f2c968dce 100644
--- a/AddMSPApp/run.ps1
+++ b/AddMSPApp/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Write-Host "PowerShell HTTP trigger function processed a request."
@@ -63,10 +63,10 @@ $Results = foreach ($Tenant in $tenants) {
} | ConvertTo-Json -Depth 15
$JSONFile = New-Item -Path ".\ChocoApps.Cache\$((New-Guid).GUID)" -Value $CompleteObject -Force -ErrorAction Stop
"Successfully added MSP App for $($Tenant.defaultDomainName) to queue. "
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant.defaultDomainName -message "MSP Application $($intunebody.Displayname) queued to add" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant.defaultDomainName -message "MSP Application $($intunebody.Displayname) queued to add" -Sev "Info"
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant.defaultDomainName -message "Failed to add MSP Application $($intunebody.Displayname) to queue" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant.defaultDomainName -message "Failed to add MSP Application $($intunebody.Displayname) to queue" -Sev "Error"
"Failed to add MSP app for $($Tenant.defaultDomainName) to queue"
}
}
diff --git a/AddOfficeApp/run.ps1 b/AddOfficeApp/run.ps1
index d676c81b0ee2..9b58588f1d78 100644
--- a/AddOfficeApp/run.ps1
+++ b/AddOfficeApp/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -67,17 +67,17 @@ $results = foreach ($Tenant in $tenants) {
"Office deployment already exists for $($Tenant)"
Continue
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Added Office profile to $($tenant)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Added Office profile to $($tenant)" -Sev "Info"
if ($AssignTo) {
$AssignO365 = if ($AssignTo -ne "AllDevicesAndUsers") { '{"mobileAppAssignments":[{"@odata.type":"#microsoft.graph.mobileAppAssignment","target":{"@odata.type":"#microsoft.graph.' + $($AssignTo) + 'AssignmentTarget"},"intent":"Required"}]}' } else { '{"mobileAppAssignments":[{"@odata.type":"#microsoft.graph.mobileAppAssignment","target":{"@odata.type":"#microsoft.graph.allDevicesAssignmentTarget"},"intent":"Required"},{"@odata.type":"#microsoft.graph.mobileAppAssignment","target":{"@odata.type":"#microsoft.graph.allLicensedUsersAssignmentTarget"},"intent":"Required"}]}' } Write-Host ($AssignO365)
New-graphPostRequest -Uri "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$($OfficeAppID.id)/assign" -tenantid $tenant -Body $AssignO365 -type POST
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Assigned Office to $AssignTo" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Assigned Office to $AssignTo" -Sev "Info"
}
"Succesfully added Office Application for $($Tenant)"
}
catch {
"Failed to add Office App for $($Tenant): $($_.Exception.Message)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Failed adding Autopilot Profile $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APIName -tenant $($tenant) -message "Failed adding Autopilot Profile $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
continue
}
diff --git a/AddPolicy/run.ps1 b/AddPolicy/run.ps1
index d63642c550d3..767d46de17ea 100644
--- a/AddPolicy/run.ps1
+++ b/AddPolicy/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Tenants = ($Request.body | Select-Object Select_*).psobject.properties.value
if ("AllTenants" -in $Tenants) { $Tenants = (Get-Tenants).DefaultDomainName }
@@ -49,17 +49,17 @@ $results = foreach ($Tenant in $tenants) {
}
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Added policy $($Displayname)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Added policy $($Displayname)" -Sev "Error"
if ($AssignTo) {
$AssignBody = if ($AssignTo -ne "AllDevicesAndUsers") { '{"assignments":[{"id":"","target":{"@odata.type":"#microsoft.graph.' + $($AssignTo) + 'AssignmentTarget"}}]}' } else { '{"assignments":[{"id":"","target":{"@odata.type":"#microsoft.graph.allDevicesAssignmentTarget"}},{"id":"","target":{"@odata.type":"#microsoft.graph.allLicensedUsersAssignmentTarget"}}]}' }
$assign = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$TemplateTypeURL('$($CreateRequest.id)')/assign" -tenantid $tenant -type POST -body $AssignBody
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Assigned policy $($Displayname) to $AssignTo" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Assigned policy $($Displayname) to $AssignTo" -Sev "Info"
}
"Succesfully added policy for $($Tenant)"
}
catch {
"Failed to add policy for $($Tenant): $($_.Exception.Message)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed adding policy $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed adding policy $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
continue
}
diff --git a/AddSharedMailbox/run.ps1 b/AddSharedMailbox/run.ps1
index a77aa7e9be06..1e15465e8a6d 100644
--- a/AddSharedMailbox/run.ps1
+++ b/AddSharedMailbox/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$groupobj = $Request.body
$user = $request.headers.'x-ms-client-principal'
@@ -24,11 +24,11 @@ try {
New-ExoRequest -tenantid $Request.body.tenantid -cmdlet "New-Mailbox" -cmdparams $BodyToship
$body = [pscustomobject]@{"Results" = "Succesfully created shared mailbox." }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($groupobj.tenantid) -message "Created group $($groupobj.displayname) with id $($GraphRequest.id) for " -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($groupobj.tenantid) -message "Created group $($groupobj.displayname) with id $($GraphRequest.id) for " -Sev "Info"
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($groupobj.tenantid) -message "Group creation API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($groupobj.tenantid) -message "Group creation API failed. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to create group. $($_.Exception.Message)" }
}
diff --git a/AddStandardsDeploy/run.ps1 b/AddStandardsDeploy/run.ps1
index b0435c9528a6..b07082038362 100644
--- a/AddStandardsDeploy/run.ps1
+++ b/AddStandardsDeploy/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$user = $request.headers.'x-ms-client-principal'
$username = ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($user)) | ConvertFrom-Json).userDetails
@@ -25,7 +25,7 @@ try {
$body = [pscustomobject]@{"Results" = "Successfully added standards deployment" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Standards API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Standards API failed. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to add standard: $($_.Exception.Message)" }
}
diff --git a/AddTeam/run.ps1 b/AddTeam/run.ps1
index 246e471fe00f..b7750696392c 100644
--- a/AddTeam/run.ps1
+++ b/AddTeam/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$userobj = $Request.body
@@ -34,12 +34,12 @@ try {
Write-Host $TeamsSettings
New-GraphPostRequest -AsApp $true -uri "https://graph.microsoft.com/beta/teams" -tenantid $Userobj.tenantid -type POST -body $TeamsSettings -verbose
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Added Team $($userobj.displayname)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Added Team $($userobj.displayname)" -Sev "Info"
$body = [pscustomobject]@{"Results" = "Success. Team has been added" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "$($userobj.tenantid): Add Team failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "$($userobj.tenantid): Add Team failed. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed. Error message: $($_.Exception.Message)" }
}
diff --git a/AddTransportRule/run.ps1 b/AddTransportRule/run.ps1
index 576063c3cf1f..4c1bd2442543 100644
--- a/AddTransportRule/run.ps1
+++ b/AddTransportRule/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$RequestParams = $Request.Body.PowerShellCommand | ConvertFrom-Json | Select-Object -Property * -ExcludeProperty GUID
@@ -13,7 +13,7 @@ $Result = foreach ($Tenantfilter in $tenants) {
try {
$GraphRequest = New-ExoRequest -tenantid $Tenantfilter -cmdlet "New-TransportRule" -cmdParams $RequestParams
"Succesfully created transport rule for $tenantfilter."
- Log-request -API $APINAME -tenant $tenantfilter -message "Created transport rule for $($tenantfilter)" -sev Debug
+ Write-LogMessage -API $APINAME -tenant $tenantfilter -message "Created transport rule for $($tenantfilter)" -sev Debug
}
catch {
"Could not create created transport rule for $($tenantfilter): $($_.Exception.message)"
diff --git a/AddTransportTemplate/run.ps1 b/AddTransportTemplate/run.ps1
index c07959ff1886..9f45e46443a5 100644
--- a/AddTransportTemplate/run.ps1
+++ b/AddTransportTemplate/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Write-Host ($request | ConvertTo-Json -Compress)
try {
@@ -22,12 +22,12 @@ try {
}
$JSON = ($JSON | ConvertTo-Json -Depth 10).tolower()
Set-Content "Config\$($GUID).TransportRuleTemplate.json" -Value ($JSON) -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created Transport Rule Template $($Request.body.name) with GUID $GUID" -Sev "Debug"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created Transport Rule Template $($Request.body.name) with GUID $GUID" -Sev "Debug"
$body = [pscustomobject]@{"Results" = "Successfully added template" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to create Transport Rule Template: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to create Transport Rule Template: $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Intune Template Deployment failed: $($_.Exception.Message)" }
}
diff --git a/AddUser/run.ps1 b/AddUser/run.ps1
index c01aff6911f2..55d157073b1b 100644
--- a/AddUser/run.ps1
+++ b/AddUser/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Results = [System.Collections.ArrayList]@()
$userobj = $Request.body
# Write to the Azure Functions log stream.
@@ -28,13 +28,13 @@ try {
}
} | ConvertTo-Json
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users" -tenantid $Userobj.tenantid -type POST -body $BodyToship -verbose
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Created user $($userobj.displayname) with id $($GraphRequest.id) " -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Created user $($userobj.displayname) with id $($GraphRequest.id) " -Sev "Info"
$results.add("Created user.")
$results.add("Username: $($UserprincipalName)")
$results.add("Password: $password")
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "User creation API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "User creation API failed. $($_.Exception.Message)" -Sev "Error"
$body = $results.add("Failed to create user. $($_.Exception.Message)" )
}
@@ -52,14 +52,14 @@ try {
}
Write-Host $LicenseBody
$LicRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($GraphRequest.id)/assignlicense" -tenantid $Userobj.tenantid -type POST -body $LicenseBody -verbose
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Assigned user $($userobj.displayname) license $($licences)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Assigned user $($userobj.displayname) license $($licences)" -Sev "Info"
$body = $results.add("Assigned licenses.")
}
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "License assign API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "License assign API failed. $($_.Exception.Message)" -Sev "Error"
$body = $results.add("We've failed to assign the license. $($_.Exception.Message)")
}
@@ -70,12 +70,12 @@ try {
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($GraphRequest.id)" -tenantid $Userobj.tenantid -type "patch" -body "{`"mail`": `"$Alias`"}" -verbose
}
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($GraphRequest.id)" -tenantid $Userobj.tenantid -type "patch" -body "{`"mail`": `"$UserprincipalName`"}" -verbose
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Added alias $($Alias) to $($userobj.displayname)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Added alias $($Alias) to $($userobj.displayname)" -Sev "Info"
$body = $results.add("Added Aliases: $($Aliases -join ',')")
}
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Alias API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Alias API failed. $($_.Exception.Message)" -Sev "Error"
$body = $results.add("We've failed to create the Aliases: $($_.Exception.Message)")
}
if ($Request.body.CopyFrom -ne "") {
@@ -86,12 +86,12 @@ if ($Request.body.CopyFrom -ne "") {
$groupname = (New-GraphGetRequest -tenantid $Userobj.tenantid -asApp $true -uri "https://graph.microsoft.com/beta/groups/$($_)").displayName
Write-Host "name: $groupname"
$GroupResult = New-GraphPostRequest -AsApp $true -uri "https://graph.microsoft.com/beta/groups/$($_)" -tenantid $Userobj.tenantid -type patch -body $addmemberbody -Verbose
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Added $($UserprincipalName) to group $groupresult.displayName)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Added $($UserprincipalName) to group $groupresult.displayName)" -Sev "Info" -tenant $TenantFilter
$body = $results.add("Added group: $($groupname)")
}
catch {
$body = $results.add("We've failed to add the group $($groupname): $($_.Exception.Message)")
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Alias API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Alias API failed. $($_.Exception.Message)" -Sev "Error"
}
}
diff --git a/Applications_Orchestrator/run.ps1 b/Applications_Orchestrator/run.ps1
index 0dac94675655..dca4493bceca 100644
--- a/Applications_Orchestrator/run.ps1
+++ b/Applications_Orchestrator/run.ps1
@@ -14,5 +14,5 @@ catch {
Write-Host "Applications_Orchestrator exception: $($_.Exception.Message)"
}
finally {
- Log-request -API 'ChocoApp' -Message 'Choco Application Queue: Deployment finished.' -sev Info
+ Write-LogMessage -API 'ChocoApp' -Message 'Choco Application Queue: Deployment finished.' -sev Info
}
\ No newline at end of file
diff --git a/Applications_Upload/run.ps1 b/Applications_Upload/run.ps1
index 683de21cf525..fc490a25e640 100644
--- a/Applications_Upload/run.ps1
+++ b/Applications_Upload/run.ps1
@@ -45,7 +45,7 @@ foreach ($tenant in $tenants) {
Try {
$ApplicationList = (New-graphGetRequest -Uri $baseuri -tenantid $Tenant) | Where-Object { $_.DisplayName -eq $ChocoApp.ApplicationName }
if ($ApplicationList.displayname.count -ge 1) {
- Log-Request -api "AppUpload" -tenant $($Tenant) -message "$($ChocoApp.ApplicationName) exists. Skipping this application" -Sev "Info"
+ Write-LogMessage -api "AppUpload" -tenant $($Tenant) -message "$($ChocoApp.ApplicationName) exists. Skipping this application" -Sev "Info"
continue
}
$NewApp = New-GraphPostRequest -Uri $baseuri -Body ($intuneBody | ConvertTo-Json) -Type POST -tenantid $tenant
@@ -68,23 +68,23 @@ foreach ($tenant in $tenants) {
do {
$CommitStateReq = New-graphGetRequest -Uri "$($BaseURI)/$($NewApp.id)/microsoft.graph.win32lobapp/contentVersions/1/files/$($ContentReq.id)" -tenantid $tenant
if ($CommitStateReq.uploadState -like "*fail*") {
- Log-Request -api "AppUpload" -tenant $($Tenant) -message "$($ChocoApp.ApplicationName) Commit failed. Please check if app uploaded succesful" -Sev "Warning"
+ Write-LogMessage -api "AppUpload" -tenant $($Tenant) -message "$($ChocoApp.ApplicationName) Commit failed. Please check if app uploaded succesful" -Sev "Warning"
break
}
Start-Sleep -Milliseconds 300
} while ($CommitStateReq.uploadState -eq "commitFilePending")
$CommitFinalizeReq = New-graphPostRequest -Uri "$($BaseURI)/$($NewApp.id)" -tenantid $tenant -Body '{"@odata.type":"#microsoft.graph.win32lobapp","committedContentVersion":"1"}' -type PATCH
- Log-Request -api "AppUpload" -tenant $($Tenant) -message "Added Choco app $($chocoApp.ApplicationName)" -Sev "Info"
+ Write-LogMessage -api "AppUpload" -tenant $($Tenant) -message "Added Choco app $($chocoApp.ApplicationName)" -Sev "Info"
if ($AssignTo -ne "On") {
$AssignBody = if ($AssignTo -ne "AllDevicesAndUsers") { '{"mobileAppAssignments":[{"@odata.type":"#microsoft.graph.mobileAppAssignment","target":{"@odata.type":"#microsoft.graph.' + $($AssignTo) + 'AssignmentTarget"},"intent":"Required","settings":{"@odata.type":"#microsoft.graph.win32LobAppAssignmentSettings","notifications":"hideAll","installTimeSettings":null,"restartSettings":null,"deliveryOptimizationPriority":"notConfigured"}}]}' } else { '{"mobileAppAssignments":[{"@odata.type":"#microsoft.graph.mobileAppAssignment","target":{"@odata.type":"#microsoft.graph.allDevicesAssignmentTarget"},"intent":"Required","settings":{"@odata.type":"#microsoft.graph.win32LobAppAssignmentSettings","notifications":"showAll","installTimeSettings":null,"restartSettings":null,"deliveryOptimizationPriority":"notConfigured"}},{"@odata.type":"#microsoft.graph.mobileAppAssignment","target":{"@odata.type":"#microsoft.graph.allLicensedUsersAssignmentTarget"},"intent":"Required","settings":{"@odata.type":"#microsoft.graph.win32LobAppAssignmentSettings","notifications":"showAll","installTimeSettings":null,"restartSettings":null,"deliveryOptimizationPriority":"notConfigured"}}]}' }
$assign = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$($NewApp.id)/assign" -tenantid $tenant -type POST -body $AssignBody
- Log-Request -api "AppUpload" -tenant $($Tenant) -message "Assigned application $($chocoApp.ApplicationName) to $AssignTo" -Sev "Info"
+ Write-LogMessage -api "AppUpload" -tenant $($Tenant) -message "Assigned application $($chocoApp.ApplicationName) to $AssignTo" -Sev "Info"
}
- Log-Request -api "AppUpload" -tenant $($Tenant) -message "Succesfully added Choco App"
+ Write-LogMessage -api "AppUpload" -tenant $($Tenant) -message "Succesfully added Choco App"
}
catch {
"Failed to add Choco App for $($Tenant): $($_.Exception.Message)"
- Log-Request -api "AppUpload" -tenant $($Tenant) -message "Failed adding choco App $($ChocoApp.ApplicationName). Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -api "AppUpload" -tenant $($Tenant) -message "Failed adding choco App $($ChocoApp.ApplicationName). Error: $($_.Exception.Message)" -Sev "Error"
continue
}
diff --git a/BestPracticeAnalyser_All/run.ps1 b/BestPracticeAnalyser_All/run.ps1
index 3e301d27209f..5bdc8fe5fc38 100644
--- a/BestPracticeAnalyser_All/run.ps1
+++ b/BestPracticeAnalyser_All/run.ps1
@@ -4,11 +4,11 @@ param($tenant)
$uri = "https://login.microsoftonline.com/$($Tenant)/oauth2/token"
$body = "resource=https://admin.microsoft.com&grant_type=refresh_token&refresh_token=$($ENV:ExchangeRefreshToken)"
try {
- $token = Invoke-RestMethod $uri -Body $body -ContentType "application/x-www-form-urlencoded" -ErrorAction SilentlyContinue -Method post
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Token retrieved for Best Practice Analyser on $($tenant)" -sev "Info"
+ $token = Invoke-RestMethod $uri -Body $body -ContentType 'application/x-www-form-urlencoded' -ErrorAction SilentlyContinue -Method post
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Token retrieved for Best Practice Analyser on $($tenant)" -sev 'Info'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Unable to Retrieve token for Best Practice Analyser $($tenant) Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Unable to Retrieve token for Best Practice Analyser $($tenant) Error: $($_.exception.message)" -sev 'Error'
}
$TenantName = Get-Tenants | Where-Object -Property DefaultDomainName -EQ $tenant
# Build up the result object that will be passed back to the durable function
@@ -16,110 +16,110 @@ $Result = [PSCustomObject]@{
Tenant = $TenantName.displayname
GUID = $TenantName.CustomerId
LastRefresh = $(Get-Date (Get-Date).ToUniversalTime() -UFormat '+%Y-%m-%dT%H:%M:%S.000Z')
- SecureDefaultState = ""
- PrivacyEnabled = ""
- UnifiedAuditLog = ""
- MessageCopyForSend = ""
- MessageCopyForSendAsCount = ""
- MessageCopyForSendOnBehalfCount = ""
- MessageCopyForSendList = ""
- ShowBasicAuthSettings = ""
- EnableModernAuth = ""
- AllowBasicAuthActiveSync = ""
- AllowBasicAuthImap = ""
- AllowBasicAuthPop = ""
- AllowBasicAuthWebServices = ""
- AllowBasicAuthPowershell = ""
- AllowBasicAuthAutodiscover = ""
- AllowBasicAuthMapi = ""
- AllowBasicAuthOfflineAddressBook = ""
- AllowBasicAuthRpc = ""
- AllowBasicAuthSmtp = ""
- AdminConsentForApplications = ""
- DoNotExpirePasswords = ""
- SelfServicePasswordReset = ""
- DisabledSharedMailboxLogins = ""
- DisabledSharedMailboxLoginsCount = ""
- UnusedLicensesCount = ""
- UnusedLicensesTotal = ""
- UnusedLicensesResult = ""
- UnusedLicenseList = ""
- SecureScoreCurrent = ""
- SecureScoreMax = ""
- SecureScorePercentage = ""
+ SecureDefaultState = ''
+ PrivacyEnabled = ''
+ UnifiedAuditLog = ''
+ MessageCopyForSend = ''
+ MessageCopyForSendAsCount = ''
+ MessageCopyForSendOnBehalfCount = ''
+ MessageCopyForSendList = ''
+ ShowBasicAuthSettings = ''
+ EnableModernAuth = ''
+ AllowBasicAuthActiveSync = ''
+ AllowBasicAuthImap = ''
+ AllowBasicAuthPop = ''
+ AllowBasicAuthWebServices = ''
+ AllowBasicAuthPowershell = ''
+ AllowBasicAuthAutodiscover = ''
+ AllowBasicAuthMapi = ''
+ AllowBasicAuthOfflineAddressBook = ''
+ AllowBasicAuthRpc = ''
+ AllowBasicAuthSmtp = ''
+ AdminConsentForApplications = ''
+ DoNotExpirePasswords = ''
+ SelfServicePasswordReset = ''
+ DisabledSharedMailboxLogins = ''
+ DisabledSharedMailboxLoginsCount = ''
+ UnusedLicensesCount = ''
+ UnusedLicensesTotal = ''
+ UnusedLicensesResult = ''
+ UnusedLicenseList = ''
+ SecureScoreCurrent = ''
+ SecureScoreMax = ''
+ SecureScorePercentage = ''
}
# Starting the Best Practice Analyser
# Get the Secure Default State
try {
- $SecureDefaultsState = (New-GraphGetRequest -Uri "https://graph.microsoft.com/beta/policies/identitySecurityDefaultsEnforcementPolicy" -tenantid $tenant)
+ $SecureDefaultsState = (New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/policies/identitySecurityDefaultsEnforcementPolicy' -tenantid $tenant)
$Result.SecureDefaultState = $SecureDefaultsState.IsEnabled
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Security Defaults State on $($tenant) is $($SecureDefaultsState.IsEnabled)" -sev "Debug"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Security Defaults State on $($tenant) is $($SecureDefaultsState.IsEnabled)" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Security Defaults State on $($tenant) Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Security Defaults State on $($tenant) Error: $($_.exception.message)" -sev 'Error'
}
# Get the Privacy Enabled State
try {
- $Result.PrivacyEnabled = Invoke-RestMethod -ContentType "application/json;charset=UTF-8" -Uri 'https://admin.microsoft.com/admin/api/reports/config/GetTenantConfiguration' -Method Get -Headers @{
+ $Result.PrivacyEnabled = Invoke-RestMethod -ContentType 'application/json;charset=UTF-8' -Uri 'https://admin.microsoft.com/admin/api/reports/config/GetTenantConfiguration' -Method Get -Headers @{
Authorization = "Bearer $($token.access_token)";
- "x-ms-client-request-id" = [guid]::NewGuid().ToString();
- "x-ms-client-session-id" = [guid]::NewGuid().ToString()
+ 'x-ms-client-request-id' = [guid]::NewGuid().ToString();
+ 'x-ms-client-session-id' = [guid]::NewGuid().ToString()
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
} | Select-Object -ExpandProperty Output | ConvertFrom-Json | Select-Object -ExpandProperty PrivacyEnabled
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Privacy Enabled State on $($tenant) is $($Result.PrivacyEnabled)" -sev "Debug"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Privacy Enabled State on $($tenant) is $($Result.PrivacyEnabled)" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Privacy Enabled State on $($tenant) Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Privacy Enabled State on $($tenant) Error: $($_.exception.message)" -sev 'Error'
}
# Get Send and Send Behalf Of
try {
# Send and Send Behalf Of
- $MailboxBPA = New-ExoRequest -tenantid $Tenant -cmdlet "Get-Mailbox" | Where-Object { $_.RecipientTypeDetails -In @("UserMailbox", "SharedMailbox") -and $_.userPrincipalName -notlike "DiscoverySearchMailbox" }
+ $MailboxBPA = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-Mailbox' | Where-Object { $_.RecipientTypeDetails -In @('UserMailbox', 'SharedMailbox') -and $_.userPrincipalName -notlike 'DiscoverySearchMailbox' }
$TotalMailboxes = $MailboxBPA | Measure-Object | Select-Object -ExpandProperty Count
$TotalMessageCopyForSentAsEnabled = $MailboxBPA | Where-Object { $_.MessageCopyForSentAsEnabled -eq $true } | Measure-Object | Select-Object -ExpandProperty Count
$TotalMessageCopyForSendOnBehalfEnabled = $MailboxBPA | Where-Object { $_.MessageCopyForSendOnBehalfEnabled -eq $true } | Measure-Object | Select-Object -ExpandProperty Count
If (($TotalMailboxes -eq $TotalMessageCopyForSentAsEnabled) -and ($TotalMailboxes -eq $TotalMessageCopyForSendOnBehalfEnabled)) {
- $Result.MessageCopyForSend = "PASS"
+ $Result.MessageCopyForSend = 'PASS'
$Result.MessageCopyForSendAsCount = $TotalMessageCopyForSentAsEnabled
$Result.MessageCopyForSendOnBehalfCount = $TotalMessageCopyForSendOnBehalfEnabled
}
else {
- $Result.MessageCopyForSend = "FAIL"
+ $Result.MessageCopyForSend = 'FAIL'
$Result.MessageCopyForSendAsCount = $MailboxBPA | Where-Object { $_.MessageCopyForSentAsEnabled -eq $false } | Measure-Object | Select-Object -ExpandProperty Count
$Result.MessageCopyForSendOnBehalfCount = $MailboxBPA | Where-Object { $_.MessageCopyForSendOnBehalfEnabled -eq $false } | Measure-Object | Select-Object -ExpandProperty Count
- $Result.MessageCopyForSendList = ($MailboxBPA | Where-Object { ($_.MessageCopyForSendOnBehalfEnabled -eq $false) -or ( $_.MessageCopyForSendOnBehalfEnabled -eq $false) } | Select-Object -ExpandProperty userPrincipalName) -join "
"
+ $Result.MessageCopyForSendList = ($MailboxBPA | Where-Object { ($_.MessageCopyForSendOnBehalfEnabled -eq $false) -or ( $_.MessageCopyForSendOnBehalfEnabled -eq $false) } | Select-Object -ExpandProperty userPrincipalName) -join '
'
}
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Send and Send Behalf Of on $($tenant) is $($Result.MessageCopyForSend)" -sev "Debug"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Send and Send Behalf Of on $($tenant) is $($Result.MessageCopyForSend)" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Send and Send Behalf Of on $($tenant) Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Send and Send Behalf Of on $($tenant) Error: $($_.exception.message)" -sev 'Error'
}
# Get Unified Audit Log
try {
- $EXOAdminAuditLogConfig = New-ExoRequest -tenantid $Tenant -cmdlet "Get-AdminAuditLogConfig"
+ $EXOAdminAuditLogConfig = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AdminAuditLogConfig'
$Result.UnifiedAuditLog = $EXOAdminAuditLogConfig | Select-Object -ExpandProperty UnifiedAuditLogIngestionEnabled
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Unified Audit Log on $($tenant) is $($Result.UnifiedAuditLog)" -sev "Debug"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Unified Audit Log on $($tenant) is $($Result.UnifiedAuditLog)" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Unified Audit Log on $($tenant). Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Unified Audit Log on $($tenant). Error: $($_.exception.message)" -sev 'Error'
}
# Get Basic Auth States
try {
- $BasicAuthDisable = Invoke-RestMethod -ContentType "application/json;charset=UTF-8" -Uri 'https://admin.microsoft.com/admin/api/services/apps/modernAuth' -Method GET -Headers @{
+ $BasicAuthDisable = Invoke-RestMethod -ContentType 'application/json;charset=UTF-8' -Uri 'https://admin.microsoft.com/admin/api/services/apps/modernAuth' -Method GET -Headers @{
Authorization = "Bearer $($token.access_token)";
- "x-ms-client-request-id" = [guid]::NewGuid().ToString();
- "x-ms-client-session-id" = [guid]::NewGuid().ToString()
+ 'x-ms-client-request-id' = [guid]::NewGuid().ToString();
+ 'x-ms-client-session-id' = [guid]::NewGuid().ToString()
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
}
@@ -135,58 +135,58 @@ try {
$Result.AllowBasicAuthOfflineAddressBook = $BasicAuthDisable.AllowBasicAuthOfflineAddressBook
$Result.AllowBasicAuthRpc = $BasicAuthDisable.AllowBasicAuthRpc
$Result.AllowBasicAuthSmtp = $BasicAuthDisable.AllowBasicAuthSmtp
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Basic Auth States on $($tenant) run" -sev "Debug"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Basic Auth States on $($tenant) run" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Basic Auth States on $($tenant). Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Basic Auth States on $($tenant). Error: $($_.exception.message)" -sev 'Error'
}
# Get OAuth Admin Consenst
try {
$GraphRequest = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy' -tenantid $Tenant -asApp $true
- $Result.AdminConsentForApplications = if ($GraphRequest.permissionGrantPolicyIdsAssignedToDefaultUserRole -eq "ManagePermissionGrantsForSelf.microsoft-user-default-legacy") { $true } else { $false }
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "OAuth Admin Consent on $($tenant). Admin Consent for Applications $($Result.AdminConsentForApplications) and password reset is $($Result.SelfServicePasswordReset)" -sev "Debug"
+ $Result.AdminConsentForApplications = if ($GraphRequest.permissionGrantPolicyIdsAssignedToDefaultUserRole -eq 'ManagePermissionGrantsForSelf.microsoft-user-default-legacy') { $true } else { $false }
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "OAuth Admin Consent on $($tenant). Admin Consent for Applications $($Result.AdminConsentForApplications) and password reset is $($Result.SelfServicePasswordReset)" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "OAuth Admin Consent on $($tenant). Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "OAuth Admin Consent on $($tenant). Error: $($_.exception.message)" -sev 'Error'
}
# Get Self Service Password Reset State
try {
$bodypasswordresetpol = "resource=74658136-14ec-4630-ad9b-26e160ff0fc6&grant_type=refresh_token&refresh_token=$($ENV:ExchangeRefreshToken)"
- $tokensspr = Invoke-RestMethod $uri -Body $bodypasswordresetpol -ContentType "application/x-www-form-urlencoded" -ErrorAction SilentlyContinue -Method post
- $SSPRGraph = Invoke-RestMethod -ContentType "application/json;charset=UTF-8" -Uri 'https://main.iam.ad.ext.azure.com/api/PasswordReset/PasswordResetPolicies' -Method GET -Headers @{
+ $tokensspr = Invoke-RestMethod $uri -Body $bodypasswordresetpol -ContentType 'application/x-www-form-urlencoded' -ErrorAction SilentlyContinue -Method post
+ $SSPRGraph = Invoke-RestMethod -ContentType 'application/json;charset=UTF-8' -Uri 'https://main.iam.ad.ext.azure.com/api/PasswordReset/PasswordResetPolicies' -Method GET -Headers @{
Authorization = "Bearer $($tokensspr.access_token)";
- "x-ms-client-request-id" = [guid]::NewGuid().ToString();
- "x-ms-client-session-id" = [guid]::NewGuid().ToString()
+ 'x-ms-client-request-id' = [guid]::NewGuid().ToString();
+ 'x-ms-client-session-id' = [guid]::NewGuid().ToString()
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
}
- If ($SSPRGraph.enablementType -eq 0) { $Result.SelfServicePasswordReset = "Off" }
- If ($SSPRGraph.enablementType -eq 1) { $Result.SelfServicePasswordReset = "Specific Users" }
- If ($SSPRGraph.enablementType -eq 2) { $Result.SelfServicePasswordReset = "On" }
- If ([string]::IsNullOrEmpty($SSPRGraph.enablementType)) { $Result.SelfServicePasswordReset = "Unknown" }
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Basic Self Service Password State on $($tenant) is $($Result.SelfServicePasswordReset) run" -sev "Debug"
+ If ($SSPRGraph.enablementType -eq 0) { $Result.SelfServicePasswordReset = 'Off' }
+ If ($SSPRGraph.enablementType -eq 1) { $Result.SelfServicePasswordReset = 'Specific Users' }
+ If ($SSPRGraph.enablementType -eq 2) { $Result.SelfServicePasswordReset = 'On' }
+ If ([string]::IsNullOrEmpty($SSPRGraph.enablementType)) { $Result.SelfServicePasswordReset = 'Unknown' }
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Basic Self Service Password State on $($tenant) is $($Result.SelfServicePasswordReset) run" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Self Service Password Reset on $($tenant). Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Self Service Password Reset on $($tenant). Error: $($_.exception.message)" -sev 'Error'
}
# Get Passwords set to Never Expire
try {
- $Result.DoNotExpirePasswords = Invoke-RestMethod -ContentType "application/json; charset=utf-8" -Uri 'https://admin.microsoft.com/admin/api/Settings/security/passwordpolicy' -Method GET -Headers @{Authorization = "Bearer $($token.access_token)"; "x-ms-client-request-id" = [guid]::NewGuid().ToString(); "x-ms-client-session-id" = [guid]::NewGuid().ToString(); 'X-Requested-With' = 'XMLHttpRequest'; 'x-ms-correlation-id' = [guid]::NewGuid() } | Select-Object -ExpandProperty NeverExpire
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Passwords never expire setting on $($tenant). $($Result.DoNotExpirePasswords)" -sev "Debug"
+ $Result.DoNotExpirePasswords = Invoke-RestMethod -ContentType 'application/json; charset=utf-8' -Uri 'https://admin.microsoft.com/admin/api/Settings/security/passwordpolicy' -Method GET -Headers @{Authorization = "Bearer $($token.access_token)"; 'x-ms-client-request-id' = [guid]::NewGuid().ToString(); 'x-ms-client-session-id' = [guid]::NewGuid().ToString(); 'X-Requested-With' = 'XMLHttpRequest'; 'x-ms-correlation-id' = [guid]::NewGuid() } | Select-Object -ExpandProperty NeverExpire
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Passwords never expire setting on $($tenant). $($Result.DoNotExpirePasswords)" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Passwords never expire setting on $($tenant). Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Passwords never expire setting on $($tenant). Error: $($_.exception.message)" -sev 'Error'
}
# Get Shared Mailbox Stuff
try {
- $SharedMailboxList = (New-GraphGetRequest -uri "https://outlook.office365.com/adminapi/beta/$($tenant)/Mailbox" -Tenantid $tenant -scope ExchangeOnline | Where-Object -propert RecipientTypeDetails -EQ "SharedMailbox")
- $AllUsersAccountState = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users?select=userPrincipalName,accountEnabled" -tenantid $Tenant
+ $SharedMailboxList = (New-GraphGetRequest -uri "https://outlook.office365.com/adminapi/beta/$($tenant)/Mailbox" -Tenantid $tenant -scope ExchangeOnline | Where-Object -propert RecipientTypeDetails -EQ 'SharedMailbox')
+ $AllUsersAccountState = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/users?select=userPrincipalName,accountEnabled' -tenantid $Tenant
$EnabledUsersWithSharedMailbox = foreach ($SharedMailbox in $SharedMailboxList) {
# Match the User
$User = $AllUsersAccountState | Where-Object { $_.userPrincipalName -eq $SharedMailbox.userPrincipalName } | Select-Object -First 1
@@ -195,12 +195,12 @@ try {
}
}
- if (($EnabledUsersWithSharedMailbox | Measure-Object | Select-Object -ExpandProperty Count) -gt 0) { $Result.DisabledSharedMailboxLogins = ($EnabledUsersWithSharedMailbox) -join "
" } else { $Result.DisabledSharedMailboxLogins = "PASS" }
+ if (($EnabledUsersWithSharedMailbox | Measure-Object | Select-Object -ExpandProperty Count) -gt 0) { $Result.DisabledSharedMailboxLogins = ($EnabledUsersWithSharedMailbox) -join '
' } else { $Result.DisabledSharedMailboxLogins = 'PASS' }
$Result.DisabledSharedMailboxLoginsCount = $EnabledUsersWithSharedMailbox | Measure-Object | Select-Object -ExpandProperty Count
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Shared Mailbox Enabled Accounts on $($tenant). $($Result.DisabledSharedMailboxLogins)" -sev "Debug"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Shared Mailbox Enabled Accounts on $($tenant). $($Result.DisabledSharedMailboxLogins)" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Shared Mailbox Enabled Accounts on $($tenant). Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Shared Mailbox Enabled Accounts on $($tenant). Error: $($_.exception.message)" -sev 'Error'
}
# Get unused Licenses
@@ -208,10 +208,11 @@ try {
$LicenseUsage = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $Tenant
# Import the licenses conversion table
$ConvertTable = Import-Csv Conversiontable.csv | Sort-Object -Property 'guid' -Unique
- $ExcludeList = Get-AzTableRow -Table (Get-CIPPTable -TableName ExcludedLicenses)
+ $Table = Get-CIPPTable -TableName ExcludedLicenses
+ $ExcludeList = Get-AzDataTableEntity @Table
$UnusedLicenses = $LicenseUsage | Where-Object { ($_.prepaidUnits.enabled -ne $_.consumedUnits) -and ($_.SkuID -notin $ExcludeList.GUID) }
$UnusedLicensesCount = $UnusedLicenses | Measure-Object | Select-Object -ExpandProperty Count
- $UnusedLicensesResult = if ($UnusedLicensesCount -gt 0) { "FAIL" } else { "PASS" }
+ $UnusedLicensesResult = if ($UnusedLicensesCount -gt 0) { 'FAIL' } else { 'PASS' }
$Result.UnusedLicenseList = foreach ($License in $UnusedLicenses) {
$PrettyName = ($ConvertTable | Where-Object { $_.guid -eq $License.skuid }).'Product_Display_Name' | Select-Object -Last 1
if (!$PrettyName) { $PrettyName = $License.skuPartNumber }
@@ -230,10 +231,10 @@ try {
$Result.UnusedLicensesTotal = $TempCount
$Result.UnusedLicensesCount = $UnusedLicensesCount
$Result.UnusedLicensesResult = $UnusedLicensesResult
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Unused Licenses on $($tenant). $($Result.UnusedLicensesCount) total not matching" -sev "Debug"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Unused Licenses on $($tenant). $($Result.UnusedLicensesCount) total not matching" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Unused Licenses on $($tenant). Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Unused Licenses on $($tenant). Error: $($_.exception.message)" -sev 'Error'
}
# Get Secure Score
@@ -242,12 +243,12 @@ try {
$Result.SecureScoreCurrent = $SecureScore.currentScore
$Result.SecureScoreMax = $SecureScore.maxScore
$Result.SecureScorePercentage = [int](($SecureScore.currentScore / $SecureScore.maxScore) * 100)
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Secure Score on $($tenant) is $($Result.SecureScoreCurrent) / $($Result.SecureScoreMax)" -sev "Debug"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Secure Score on $($tenant) is $($Result.SecureScoreCurrent) / $($Result.SecureScoreMax)" -sev 'Debug'
}
catch {
- Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Secure Score Retrieval on $($tenant). Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API 'BestPracticeAnalyser' -tenant $tenant -message "Secure Score Retrieval on $($tenant). Error: $($_.exception.message)" -sev 'Error'
}
+
-
-# Send Output of all the Results to the Stream
+the Results to the Stream
$Result
\ No newline at end of file
diff --git a/BestPracticeAnalyser_List/run.ps1 b/BestPracticeAnalyser_List/run.ps1
index e27cf5bc09b2..1be15f794fe7 100644
--- a/BestPracticeAnalyser_List/run.ps1
+++ b/BestPracticeAnalyser_List/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/BestPracticeAnalyser_Orchestration/run.ps1 b/BestPracticeAnalyser_Orchestration/run.ps1
index 2c9a820e3b4a..4e329cda7bda 100644
--- a/BestPracticeAnalyser_Orchestration/run.ps1
+++ b/BestPracticeAnalyser_Orchestration/run.ps1
@@ -1,6 +1,6 @@
param($Context)
-Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Best Practice Analyser has Started" -sev Info
+Write-LogMessage -API "BestPracticeAnalyser" -tenant $tenant -message "Best Practice Analyser has Started" -sev Info
New-Item "Cache_BestPracticeAnalyser" -ItemType Directory -ErrorAction SilentlyContinue
New-Item "Cache_BestPracticeAnalyser\CurrentlyRunning.txt" -ItemType File -Force
$Batch = (Invoke-ActivityFunction -FunctionName 'BestPracticeAnalyser_GetQueue' -Input 'LetsGo')
@@ -17,5 +17,5 @@ foreach ($item in $Outputs) {
Set-Content "Cache_BestPracticeAnalyser\$($item.tenant).BestPracticeAnalysis.json" -Value $Object -Force
}
-Log-request -API "BestPracticeAnalyser" -tenant $tenant -message "Best Practice Analyser has Finished" -sev Info
+Write-LogMessage -API "BestPracticeAnalyser" -tenant $tenant -message "Best Practice Analyser has Finished" -sev Info
Remove-Item "Cache_BestPracticeAnalyser\CurrentlyRunning.txt" -Force
\ No newline at end of file
diff --git a/BestPracticeAnalyser_OrchestrationStarter/run.ps1 b/BestPracticeAnalyser_OrchestrationStarter/run.ps1
index 6203a3d50cae..bb74b0c8a045 100644
--- a/BestPracticeAnalyser_OrchestrationStarter/run.ps1
+++ b/BestPracticeAnalyser_OrchestrationStarter/run.ps1
@@ -4,13 +4,13 @@ param($Request, $TriggerMetadata)
$CurrentlyRunning = Get-Item "Cache_BestPracticeAnalyser\CurrentlyRunning.txt" -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{"Results" = "Already running. Please wait for the current instance to finish" }
- Log-request -API "BestPracticeAnalyser" -message "Attempted to start analysis but an instance was already running." -sev Info
+ Write-LogMessage -API "BestPracticeAnalyser" -message "Attempted to start analysis but an instance was already running." -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName 'BestPracticeAnalyser_Orchestration'
Write-Host "Started orchestration with ID = '$InstanceId'"
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId
- Log-request -API "BestPracticeAnalyser" -message "Started retrieving best practice information" -sev Info
+ Write-LogMessage -API "BestPracticeAnalyser" -message "Started retrieving best practice information" -sev Info
$Results = [pscustomobject]@{"Results" = "Started running analysis" }
}
Write-Host ($Orchestrator | ConvertTo-Json)
diff --git a/BestPracticeAnalyser_OrchestrationStarterTimer/run.ps1 b/BestPracticeAnalyser_OrchestrationStarterTimer/run.ps1
index 0ff4ca19bd4f..ea8ae8066732 100644
--- a/BestPracticeAnalyser_OrchestrationStarterTimer/run.ps1
+++ b/BestPracticeAnalyser_OrchestrationStarterTimer/run.ps1
@@ -4,13 +4,13 @@ try {
$CurrentlyRunning = Get-Item 'Cache_BestPracticeAnalyser\CurrentlyRunning.txt' -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' }
- Log-request -API 'BestPracticeAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info
+ Write-LogMessage -API 'BestPracticeAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName 'BestPracticeAnalyser_Orchestration'
Write-Host "Started orchestration with ID = '$InstanceId'"
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Timer -InstanceId $InstanceId
- Log-request -API 'BestPracticeAnalyser' -message 'Started retrieving best practice information' -sev Info
+ Write-LogMessage -API 'BestPracticeAnalyser' -message 'Started retrieving best practice information' -sev Info
$Results = [pscustomobject]@{'Results' = 'Started running analysis' }
}
Write-Host ($Orchestrator | ConvertTo-Json)
diff --git a/DomainAnalyser_All/run.ps1 b/DomainAnalyser_All/run.ps1
index 37dd3979e1a8..bd55b7786ec8 100644
--- a/DomainAnalyser_All/run.ps1
+++ b/DomainAnalyser_All/run.ps1
@@ -1,18 +1,19 @@
param($DomainObject)
Import-Module '.\DNSHelper.psm1'
-
$Domain = $DomainObject.rowKey
try {
- $Tenant = $DomainObject.TenantDetails | ConvertFrom-Json
+ $Tenant = $DomainObject.TenantDetails | ConvertFrom-Json -ErrorAction Stop
}
catch {
+ $Tenant = @{Tenant = 'None' }
}
-Log-request -API 'DomainAnalyser' -tenant $tenant.tenant -message "Starting Processing of $Domain" -sev Debug
+Write-LogMessage -API 'DomainAnalyser' -tenant $tenant.tenant -message "Starting Processing of $Domain" -sev Debug
+
$Result = [PSCustomObject]@{
- Tenant = $DomainObject.partitionKey
+ Tenant = $Tenant.Tenant
GUID = $($Domain.Replace('.', ''))
LastRefresh = $(Get-Date (Get-Date).ToUniversalTime() -UFormat '+%Y-%m-%dT%H:%M:%S.000Z')
Domain = $Domain
@@ -94,7 +95,7 @@ try {
}
}
catch {
- Log-request -API 'DomainAnalyser' -tenant $tenant.tenant -message "Exception while getting SPF Record with $($_.Exception.Message)" -sev Error
+ Write-LogMessage -API 'DomainAnalyser' -tenant $tenant.tenant -message "Exception while getting SPF Record with $($_.Exception.Message)" -sev Error
throw $_.Exception.Message
}
@@ -161,7 +162,7 @@ try {
}
}
catch {
- Log-request -API 'DomainAnalyser' -tenant $tenant.tenant -message "Exception while getting DMARC Record with $($_.Exception.Message)" -sev Error
+ Write-LogMessage -API 'DomainAnalyser' -tenant $tenant.tenant -message "Exception while getting DMARC Record with $($_.Exception.Message)" -sev Error
throw $_.Exception.Message
}
@@ -180,7 +181,7 @@ try {
}
}
catch {
- Log-request -API 'DomainAnalyser' -tenant $tenant.tenant -message "Exception while getting DNSSEC with $($_.Exception.Message)" -sev Error
+ Write-LogMessage -API 'DomainAnalyser' -tenant $tenant.tenant -message "Exception while getting DNSSEC with $($_.Exception.Message)" -sev Error
throw $_.Exception.Message
}
@@ -208,7 +209,7 @@ try {
}
}
catch {
- Log-request -API 'DomainAnalyser' -tenant $tenant.tenant -message "DKIM Lookup Failed with $($_.Exception.Message)" -sev Error
+ Write-LogMessage -API 'DomainAnalyser' -tenant $tenant.tenant -message "DKIM Lookup Failed with $($_.Exception.Message)" -sev Error
throw $_.Exception.Message
}
# Final Score
@@ -217,9 +218,9 @@ $Result.ScorePercentage = [int](($Result.Score / $Result.MaximumScore) * 100)
$Result.ScoreExplanation = ($ScoreExplanation) -join ', '
-$DomainObject.DomainAnalyser = ($Result | ConvertTo-Json)
+$DomainObject.DomainAnalyser = ($Result | ConvertTo-Json -Compress).ToString()
# Final Write to Output
-Log-request -API 'DomainAnalyser' -tenant $tenant.tenant -message "DNS Analyser Finished For $Domain" -sev Info
+Write-LogMessage -API 'DomainAnalyser' -tenant $tenant.tenant -message "DNS Analyser Finished For $Domain" -sev Info
-Write-Output $DomainObject
+Write-Output $DomainObject
\ No newline at end of file
diff --git a/DomainAnalyser_GetTenantDomains/run.ps1 b/DomainAnalyser_GetTenantDomains/run.ps1
index ec44f3e56b87..76e935e7b60f 100644
--- a/DomainAnalyser_GetTenantDomains/run.ps1
+++ b/DomainAnalyser_GetTenantDomains/run.ps1
@@ -1,8 +1,11 @@
param($name)
$Tenants = Get-Tenants
+$DomainTable = Get-CippTable -tablename 'Domains'
-$object = foreach ($Tenant in $Tenants) {
+$TenantDomains = $Tenants | ForEach-Object -Parallel {
+ Import-Module '.\GraphHelper.psm1'
+ $Tenant = $_
# Get Domains to Lookup
try {
$Domains = New-GraphGetRequest -uri 'https://graph.microsoft.com/v1.0/domains' -tenantid $Tenant.defaultDomainName | Where-Object { ($_.id -notlike '*.onmicrosoft.com' -and $_.id -notlike '*.microsoftonline.com' -and $_.id -NotLike '*.exclaimer.cloud' -and $_.id -NotLike '*.codetwo.online') }
@@ -21,8 +24,61 @@ $object = foreach ($Tenant in $Tenants) {
}
}
catch {
- Log-request -API 'DomainAnalyser' -tenant $tenant.defaultDomainName -message "DNS Analyser GraphGetRequest Exception: $($_.Exception.Message)" -sev Error
+ Write-LogMessage -API 'DomainAnalyser' -tenant $tenant.defaultDomainName -message "DNS Analyser GraphGetRequest Exception: $($_.Exception.Message)" -sev Error
}
}
-$object
\ No newline at end of file
+$TenantCount = ($TenantDomains | Measure-Object).Count
+if ($TenantCount -gt 0) {
+ Write-Host "$TenantCount tenant Domains"
+
+ # Process tenant domain results
+ try {
+ $TenantDomainObjects = foreach ($Tenant in $TenantDomains) {
+ $TenantDetails = ($Tenant | ConvertTo-Json -Compress).ToString()
+ $Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f $Tenant.Tenant, $Tenant.Domain
+ $OldDomain = Get-AzDataTableEntity @DomainTable -Filter $Filter
+
+ if ($OldDomain) {
+ Remove-AzDataTableEntity @DomainTable -Entity $OldDomain | Out-Null
+ }
+
+ $Filter = "PartitionKey eq 'TenantDomains' and RowKey eq '{0}'" -f $Tenant.Domain
+ $Domain = Get-AzDataTableEntity @DomainTable -Filter $Filter
+
+ if (!$Domain) {
+ $DomainObject = @{
+ DomainAnalyser = ''
+ TenantDetails = $TenantDetails
+ TenantId = $Tenant.Tenant
+ DkimSelectors = ''
+ MailProviders = ''
+ RowKey = $Tenant.Domain
+ PartitionKey = 'TenantDomains'
+ }
+
+ if ($OldDomain) {
+ $DomainObject.DkimSelectors = $OldDomain.DkimSelectors
+ $DomainObject.MailProviders = $OldDomain.MailProviders
+ }
+ $Domain = $DomainObject
+ }
+ else {
+ $Domain.TenantDetails = $TenantDetails
+ if ($OldDomain) {
+ $Domain.DkimSelectors = $OldDomain.DkimSelectors
+ $Domain.MailProviders = $OldDomain.MailProviders
+ }
+ }
+ # Return domain object to list
+ $Domain
+ }
+
+ # Batch insert all tenant domains
+ try {
+ Add-AzDataTableEntity @DomainTable -Entity $TenantDomainObjects -Force
+ }
+ catch { Write-LogMessage -API 'DomainAnalyser' -message "Domain Analyser GetTenantDomains Error $($_.Exception.Message)" -sev info }
+ }
+ catch { Write-LogMessage -API 'DomainAnalyser' -message "GetTenantDomains loop exception: $($_.Exception.Message) line $($_.InvocationInfo.ScriptLineNumber)" }
+}
\ No newline at end of file
diff --git a/DomainAnalyser_List/run.ps1 b/DomainAnalyser_List/run.ps1
index 11b87d8c26c7..537e89e0f798 100644
--- a/DomainAnalyser_List/run.ps1
+++ b/DomainAnalyser_List/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
Write-Host 'PowerShell HTTP trigger function processed a request.'
@@ -20,29 +20,34 @@ if (Test-Path .\Cache_DomainAnalyser) {
foreach ($Result in $UnfilteredResults) {
$Object = $Result | ConvertFrom-Json
- $MigratePartitionKey = @{
+ <#$MigratePartitionKey = @{
Table = $DomainTable
PartitionKey = $Tenant.Tenant
RowKey = $Tenant.Domain
- }
+ }#>
+ #$OldDomain = Get-AzTableRow @MigratePartitionKey
- $OldDomain = Get-AzTableRow @MigratePartitionKey
+ $Filter = "PartitionKey eq '{0}' and RowKey eq '{1}'" -f $Tenant.Tenant, $Tenant.Domain
+ $OldDomain = Get-AzDataTableEntity @DomainTale -Filter $Filter
if ($OldDomain) {
- $OldDomain | Remove-AzTableRow -Table $DomainTable
+ #$OldDomain | Remove-AzTableRow -Table $DomainTable
+ Remove-AzDataTableEntity @DomainTable -Entity $OldDomain
}
- $ExistingDomain = @{
+ <#$ExistingDomain = @{
Table = $DomainTable
rowKey = $Object.Domain
partitionKey = 'TenantDomains'
- }
+ }#>
+ #$Domain = Get-AzTableRow @ExistingDomain
- $Domain = Get-AzTableRow @ExistingDomain
+ $Filter = "PartitionKey eq 'TenantDomains' and RowKey eq '{1}'" -f $Tenant.Domain
+ $Domain = Get-AzDataTableEntity @DomainTable -Filter $Filter
if (!$Domain) {
Write-Host 'Adding domain from cache file'
- $DomainObject = @{
+ <#$DomainObject = @{
Table = $DomainTable
rowKey = $Object.Domain
partitionKey = 'TenantDomains'
@@ -53,14 +58,23 @@ if (Test-Path .\Cache_DomainAnalyser) {
DkimSelectors = ''
MailProviders = ''
}
+ }#>
+ $DomainObject = @{
+ DomainAnalyser = ''
+ TenantDetails = $TenantDetails
+ TenantId = $Tenant.Tenant
+ DkimSelectors = ''
+ MailProviders = ''
+ rowKey = $Tenant.Domain
+ partitionKey = 'TenantDomains'
}
if ($OldDomain) {
- $DomainObject.property.DkimSelectors = $OldDomain.DkimSelectors
- $DomainObject.property.MailProviders = $OldDomain.MailProviders
+ $DomainObject.DkimSelectors = $OldDomain.DkimSelectors
+ $DomainObject.MailProviders = $OldDomain.MailProviders
}
- Add-AzTableRow @DomainObject | Out-Null
+ Add-AzDataTableEntity @DomainTable -Entity $DomainObject | Out-Null
}
else {
Write-Host 'Updating domain from cache file'
@@ -69,7 +83,7 @@ if (Test-Path .\Cache_DomainAnalyser) {
$Domain.DkimSelectors = $OldDomain.DkimSelectors
$Domain.MailProviders = $OldDomain.MailProviders
}
- $Domain | Update-AzTableRow -Table $DomainTable | Out-Null
+ Update-AzDataTableEntity @DomainTable -Entity $Domain | Out-Null
}
Remove-Item -Path ".\Cache_DomainAnalyser\$($Object.Domain).DomainAnalysis.json" | Out-Null
}
@@ -78,20 +92,21 @@ if (Test-Path .\Cache_DomainAnalyser) {
# Need to apply exclusion logic
$Skiplist = Get-Content 'ExcludedTenants' | ConvertFrom-Csv -Delimiter '|' -Header 'Name', 'User', 'Date'
-$DomainList = @{
+<#$DomainList = @{
Table = $DomainTable
SelectColumn = @('partitionKey', 'DomainAnalyser', 'TenantId')
-}
+}#>
if ($Request.Query.tenantFilter -ne 'AllTenants') {
- $DomainList.columnName = 'TenantId'
+ <#$DomainList.columnName = 'TenantId'
$DomainList.operator = 'Equal'
- $DomainList.value = $Request.Query.tenantFilter
+ $DomainList.value = $Request.Query.tenantFilter#>
+ $DomainTable.Filter = "TenantId eq '{0}'" -f $Request.Query.tenantFilter
}
try {
# Extract json from table results
- $Results = foreach ($DomainAnalyserResult in (Get-AzTableRow @DomainList).DomainAnalyser) {
+ $Results = foreach ($DomainAnalyserResult in (Get-AzDataTableEntity @DomainTable).DomainAnalyser) {
try {
if (![string]::IsNullOrEmpty($DomainAnalyserResult)) {
$Object = $DomainAnalyserResult | ConvertFrom-Json
diff --git a/DomainAnalyser_Orchestration/run.ps1 b/DomainAnalyser_Orchestration/run.ps1
index db5356e805b9..eb0c3c79d8ab 100644
--- a/DomainAnalyser_Orchestration/run.ps1
+++ b/DomainAnalyser_Orchestration/run.ps1
@@ -1,94 +1,47 @@
param($Context)
try {
- New-Item 'Cache_DomainAnalyser' -ItemType Directory -ErrorAction SilentlyContinue
- New-Item 'Cache_DomainAnalyser\CurrentlyRunning.txt' -ItemType File -Force
+ New-Item 'Cache_DomainAnalyser' -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
+ New-Item 'Cache_DomainAnalyser\CurrentlyRunning.txt' -ItemType File -Force | Out-Null
$DurableRetryOptions = @{
FirstRetryInterval = (New-TimeSpan -Seconds 5)
MaxNumberOfAttempts = 3
+ BackoffCoefficient = 2
}
$RetryOptions = New-DurableRetryOptions @DurableRetryOptions
- $DomainTable = Get-CippTable -Table Domains
- $TenantDomains = Invoke-ActivityFunction -FunctionName 'DomainAnalyser_GetTenantDomains' -Input 'Tenants'
-
- # Process tenant domain results
- foreach ($Tenant in $TenantDomains) {
- $TenantDetails = $Tenant | ConvertTo-Json
-
- $MigratePartitionKey = @{
- Table = $DomainTable
- PartitionKey = $Tenant.Tenant
- RowKey = $Tenant.Domain
- }
-
- $OldDomain = Get-AzTableRow @MigratePartitionKey
-
- if ($OldDomain) {
- $OldDomain | Remove-AzTableRow -Table $DomainTable
- }
-
- $ExistingDomain = @{
- Table = $DomainTable
- PartitionKey = 'TenantDomains'
- RowKey = $Tenant.Domain
- }
- $Domain = Get-AzTableRow @ExistingDomain
-
- if (!$Domain) {
- $DomainObject = @{
- Table = $DomainTable
- rowKey = $Tenant.Domain
- partitionKey = 'TenantDomains'
- property = @{
- DomainAnalyser = ''
- TenantDetails = $TenantDetails
- TenantId = $Tenant.Tenant
- DkimSelectors = ''
- MailProviders = ''
- }
- }
-
- if ($OldDomain) {
- $DomainObject.property.DkimSelectors = $OldDomain.DkimSelectors
- $DomainObject.property.MailProviders = $OldDomain.MailProviders
- }
- Add-AzTableRow @DomainObject | Out-Null
- }
- else {
- $Domain.TenantDetails = $TenantDetails
- if ($OldDomain) {
- $Domain.DkimSelectors = $OldDomain.DkimSelectors
- $Domain.MailProviders = $OldDomain.MailProviders
- }
- $Domain | Update-AzTableRow -Table $DomainTable | Out-Null
- }
+ # Sync tenants
+ try {
+ Invoke-ActivityFunction -FunctionName 'DomainAnalyser_GetTenantDomains' -Input 'Tenants'
}
+ catch { Write-Host "EXCEPTION: TenantDomains $($_.Exception.Message)" }
# Get list of all domains to process
- $DomainParam = @{
- Table = $DomainTable
- }
-
- $Batch = Get-AzTableRow @DomainParam
-
+ $Batch = Invoke-ActivityFunction -FunctionName 'Activity_GetAllTableRows' -Input 'Domains'
+
$ParallelTasks = foreach ($Item in $Batch) {
Invoke-DurableActivity -FunctionName 'DomainAnalyser_All' -Input $item -NoWait -RetryOptions $RetryOptions
}
-
- $Outputs = Wait-ActivityFunction -Task $ParallelTasks
- Log-request -API 'DomainAnalyser' -message "Outputs found count = $($Outputs.count)" -sev Info
-
- foreach ($DomainObject in $Outputs) {
- [PSCustomObject]$DomainObject | Update-AzTableRow @DomainParam | Out-Null
+
+ # Collect activity function results and send to database
+ $TableParams = Get-CippTable -tablename 'Domains'
+ $TableParams.Entity = Wait-ActivityFunction -Task $ParallelTasks
+ $TableParams.Force = $true
+ $TableParams = $TableParams | ConvertTo-Json -Compress
+
+ try {
+ Invoke-ActivityFunction -FunctionName 'Activity_AddOrUpdateTableRows' -Input $TableParams
+ }
+ catch {
+ Write-Host "Orchestrator exception UpdateDomains $($_.Exception.Message)"
}
}
catch {
- Log-request -API 'DomainAnalyser' -message "Domain Analyser Orchestrator Error $($_.Exception.Message)" -sev info
- Write-Host $_.Exception | ConvertTo-Json
+ Write-LogMessage -API 'DomainAnalyser' -message "Domain Analyser Orchestrator Error $($_.Exception.Message)" -sev info
+ #Write-Host $_.Exception | ConvertTo-Json
}
finally {
- Log-request -API 'DomainAnalyser' -message 'Domain Analyser has Finished' -sev Info
+ Write-LogMessage -API 'DomainAnalyser' -message 'Domain Analyser has Finished' -sev Info
Remove-Item 'Cache_DomainAnalyser\CurrentlyRunning.txt' -Force
}
\ No newline at end of file
diff --git a/DomainAnalyser_OrchestrationStarter/run.ps1 b/DomainAnalyser_OrchestrationStarter/run.ps1
index 0f11e7f698b4..ef41afd6502c 100644
--- a/DomainAnalyser_OrchestrationStarter/run.ps1
+++ b/DomainAnalyser_OrchestrationStarter/run.ps1
@@ -4,13 +4,13 @@ param($Request, $TriggerMetadata)
$CurrentlyRunning = Get-Item 'Cache_DomainAnalyser\CurrentlyRunning.txt' -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' }
- Log-request -API 'DomainAnalyser' -message 'Attempted to start domain analysis but an instance was already running.' -sev Info
+ Write-LogMessage -API 'DomainAnalyser' -message 'Attempted to start domain analysis but an instance was already running.' -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName 'DomainAnalyser_Orchestration'
Write-Host "Started orchestration with ID = '$InstanceId'"
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId
- Log-request -API 'DomainAnalyser' -message 'Started retrieving domain information' -sev Info
+ Write-LogMessage -API 'DomainAnalyser' -message 'Started retrieving domain information' -sev Info
$Results = [pscustomobject]@{'Results' = 'Started running analysis' }
}
Write-Host ($Orchestrator | ConvertTo-Json)
diff --git a/Domain_OrchestrationStarterTimer/run.ps1 b/Domain_OrchestrationStarterTimer/run.ps1
index 0c932c49ce2a..41ce21b7550d 100644
--- a/Domain_OrchestrationStarterTimer/run.ps1
+++ b/Domain_OrchestrationStarterTimer/run.ps1
@@ -4,13 +4,13 @@ try {
$CurrentlyRunning = Get-Item 'Cache_DomainAnalyser\CurrentlyRunning.txt' -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{'Results' = 'Already running. Please wait for the current instance to finish' }
- Log-request -API 'DomainAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info
+ Write-LogMessage -API 'DomainAnalyser' -message 'Attempted to start analysis but an instance was already running.' -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName 'DomainAnalyser_Orchestration'
Write-Host "Started orchestration with ID = '$InstanceId'"
$Orchestrator = New-OrchestrationCheckStatusResponse -Request $Timer -InstanceId $InstanceId
- Log-request -API 'DomainAnalyser' -message 'Starting Domain Analyser' -sev Info
+ Write-LogMessage -API 'DomainAnalyser' -message 'Starting Domain Analyser' -sev Info
$Results = [pscustomobject]@{'Results' = 'Starting Domain Analyser' }
}
Write-Host ($Orchestrator | ConvertTo-Json)
diff --git a/Durable_AlertsRun/run.ps1 b/Durable_AlertsRun/run.ps1
index 2243b263487d..d00856d2b05c 100644
--- a/Durable_AlertsRun/run.ps1
+++ b/Durable_AlertsRun/run.ps1
@@ -6,7 +6,7 @@ $context = $Context | ConvertTo-Json | ConvertFrom-Json
$GUID = $context.input.GUID
$TenantFilter = $context.input.TenantID
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Write-Host "PowerShell HTTP trigger function processed a request."
Write-Host ($Context | ConvertTo-Json)
Write-Host "Using input $TenantFilter"
diff --git a/Durable_BECRun/run.ps1 b/Durable_BECRun/run.ps1
index 9aaf8933e24a..979c4f7a89e6 100644
--- a/Durable_BECRun/run.ps1
+++ b/Durable_BECRun/run.ps1
@@ -2,7 +2,7 @@ param($Context)
#$Context does not allow itself to be cast to a pscustomobject for some reason, so we convert
$context = $Context | ConvertTo-Json | ConvertFrom-Json
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Write-Host "PowerShell HTTP trigger function processed a request."
Write-Host ($Context | ConvertTo-Json)
$TenantFilter = $Context.input.tenantfilter
@@ -118,11 +118,11 @@ try {
ChangedPasswords = @(($7dayslog | Where-Object -Property Operations -In "Change user password.", "Reset user password.").AuditData | ConvertFrom-Json)
}
- #Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Assigned $($appFilter) to $assignTo" -Sev "Info"
+ #Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Assigned $($appFilter) to $assignTo" -Sev "Info"
}
catch {
- #Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to assign app $($appFilter): $($_.Exception.Message)" -Sev "Error"
+ #Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to assign app $($appFilter): $($_.Exception.Message)" -Sev "Error"
$errMessage = Get-NormalizedError -message $_.Exception.Message
$results = [pscustomobject]@{"Results" = "$errMessage" }
}
diff --git a/Durable_IncidentsRun/run.ps1 b/Durable_IncidentsRun/run.ps1
index 769a57c42d90..9d3179090e1d 100644
--- a/Durable_IncidentsRun/run.ps1
+++ b/Durable_IncidentsRun/run.ps1
@@ -6,7 +6,7 @@ $context = $Context | ConvertTo-Json | ConvertFrom-Json
$GUID = $context.input.GUID
$TenantFilter = $context.input.TenantID
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Write-Host "PowerShell HTTP trigger function processed a request."
Write-Host ($Context | ConvertTo-Json)
Write-Host "Using input $TenantFilter"
diff --git a/EditCAPolicy/run.ps1 b/EditCAPolicy/run.ps1
index 04541ae02e24..f3027f8d045c 100644
--- a/EditCAPolicy/run.ps1
+++ b/EditCAPolicy/run.ps1
@@ -4,19 +4,19 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Tenant = $request.query.tenantFilter
$ID = $request.query.guid
$results = try {
$EditBody = "{`"state`": `"$($request.query.state)`"}"
$Request = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta//identity/conditionalAccess/policies/$($id)" -tenantid $tenant -type PATCH -body $EditBody
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Edited CA policy $($ID)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Edited CA policy $($ID)" -Sev "Error"
"Succesfully edited CA policy"
}
catch {
"Failed to add CA policy: $($_.Exception.Message)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed editing CA policy $($ID). Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed editing CA policy $($ID). Error: $($_.Exception.Message)" -Sev "Error"
continue
}
diff --git a/EditGroup/run.ps1 b/EditGroup/run.ps1
index 2158b7a54238..fc2a3bb43863 100644
--- a/EditGroup/run.ps1
+++ b/EditGroup/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Results = [System.Collections.ArrayList]@()
@@ -27,7 +27,7 @@ if ($AddMembers) {
else {
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups/$($userobj.groupid)" -tenantid $Userobj.tenantid -type patch -body $addmemberbody -Verbose
}
- Log-Request -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Added member to $($userobj.displayname) group" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Added member to $($userobj.displayname) group" -Sev "Info"
$body = $results.add("Success. $member has been added")
}
catch {
@@ -50,13 +50,13 @@ try {
else {
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups/$($userobj.groupid)/members/$($MemberInfo.id)/`$ref" -tenantid $Userobj.tenantid -type DELETE
}
- Log-Request -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Removed $($MemberInfo.UserPrincipalname) from $($userobj.displayname) group" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Removed $($MemberInfo.UserPrincipalname) from $($userobj.displayname) group" -Sev "Info"
$body = $results.add("Success. Member $_ has been removed from $($userobj.Groupid)")
}
}
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $Userobj.tenantid -message "Add member API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $Userobj.tenantid -message "Add member API failed. $($_.Exception.Message)" -Sev "Error"
$body = $results.add("Could not remove $RemoveMembers from $($userobj.Groupid). $($_.Exception.Message)")
}
@@ -68,7 +68,7 @@ try {
$ID = "https://graph.microsoft.com/beta/users/" + (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/$($_)" -tenantid $Userobj.tenantid).id
Write-Host $ID
$AddOwner = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups/$($userobj.groupid)/owners/`$ref" -tenantid $Userobj.tenantid -type POST -body ('{"@odata.id": "' + $ID + '"}')
- Log-Request -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Added owner $_ to $($userobj.displayname) group" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Added owner $_ to $($userobj.displayname) group" -Sev "Info"
$body = $results.add("Success. $_ has been added")
}
catch {
@@ -80,7 +80,7 @@ try {
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -message "Add member API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -message "Add member API failed. $($_.Exception.Message)" -Sev "Error"
}
$RemoveOwners = ($userobj.RemoveOwner).value
@@ -90,7 +90,7 @@ try {
try {
$MemberInfo = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/users/$($_)" -tenantid $Userobj.tenantid)
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups/$($userobj.groupid)/owners/$($MemberInfo.id)/`$ref" -tenantid $Userobj.tenantid -type DELETE
- Log-Request -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Removed $($MemberInfo.UserPrincipalname) from $($userobj.displayname) group" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant $Userobj.tenantid -user $request.headers.'x-ms-client-principal' -message "Removed $($MemberInfo.UserPrincipalname) from $($userobj.displayname) group" -Sev "Info"
$body = $results.add("Success. Member $_ has been removed from $($userobj.Groupid)")
}
catch {
@@ -100,7 +100,7 @@ try {
}
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $Userobj.tenantid -message "Add member API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $Userobj.tenantid -message "Add member API failed. $($_.Exception.Message)" -Sev "Error"
$body = $results.add("Could not remove $RemoveMembers from $($userobj.Groupid). $($_.Exception.Message)")
}
diff --git a/EditPolicy/run.ps1 b/EditPolicy/run.ps1
index 0e3cd19cf054..6122181a6e03 100644
--- a/EditPolicy/run.ps1
+++ b/EditPolicy/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$user = $request.headers.'x-ms-client-principal'
$Tenant = $request.body.tenantid
@@ -15,17 +15,17 @@ $AssignTo = if ($request.body.Assignto -ne "on") { $request.body.Assignto }
$results = try {
$CreateBody = '{"description":"' + $description + '","displayName":"' + $displayname + '","roleScopeTagIds":["0"]}'
$Request = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/groupPolicyConfigurations('$ID')" -tenantid $tenant -type PATCH -body $CreateBody
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Edited policy $($Displayname)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Edited policy $($Displayname)" -Sev "Error"
if ($AssignTo) {
$AssignBody = if ($AssignTo -ne "AllDevicesAndUsers") { '{"assignments":[{"id":"","target":{"@odata.type":"#microsoft.graph.' + $($AssignTo) + 'AssignmentTarget"}}]}' } else { '{"assignments":[{"id":"","target":{"@odata.type":"#microsoft.graph.allDevicesAssignmentTarget"}},{"id":"","target":{"@odata.type":"#microsoft.graph.allLicensedUsersAssignmentTarget"}}]}' }
$assign = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/groupPolicyConfigurations('$($ID)')/assign" -tenantid $tenant -type POST -body $AssignBody
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Assigned policy $($Displayname) to $AssignTo" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Assigned policy $($Displayname) to $AssignTo" -Sev "Info"
}
"Succesfully edited policy for $($Tenant)"
}
catch {
"Failed to add policy for $($Tenant): $($_.Exception.Message)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed editing policy $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed editing policy $($Displayname). Error: $($_.Exception.Message)" -Sev "Error"
continue
}
diff --git a/EditTenant/run.ps1 b/EditTenant/run.ps1
index aa467a03a0e8..85e121bdfc1b 100644
--- a/EditTenant/run.ps1
+++ b/EditTenant/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$tenantDisplayName = $request.body.displayName
$tenantDefaultDomainName = $request.body.defaultDomainName
@@ -18,7 +18,7 @@ $tokens = try {
$tenantObjectId = $allTenantsDetails.value | Where-Object { $_.customerContextId -eq $customerContextId } | Select-Object 'objectId'
} catch {
"Failed to retrieve list of tenants. Error: $($_.ExceptionMessage)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantDisplayName) -message "Failed to retrieve list of tenants. Error: $($_.Exception.Message)" -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantDisplayName) -message "Failed to retrieve list of tenants. Error: $($_.Exception.Message)" -Sev 'Error'
}
@@ -35,12 +35,12 @@ $results = if ($tenantObjectId) {
'There was an error removing the tenants cache for some reason.'
}
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Edited tenant $($Tenant)" -Sev 'Info'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Edited tenant $($Tenant)" -Sev 'Info'
"Successfully amended details for $($Tenant) and cleared tenant cache"
}
catch {
"Failed to amend details for $($Tenant): $($_.ExceptionMessage)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed amending details $($Tenant). Error: $($_.Exception.Message)" -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($Tenant) -message "Failed amending details $($Tenant). Error: $($_.Exception.Message)" -Sev 'Error'
continue
}
}
diff --git a/EditTransportRule/run.ps1 b/EditTransportRule/run.ps1
index a450be3cf0db..350e22bc9966 100644
--- a/EditTransportRule/run.ps1
+++ b/EditTransportRule/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Tenantfilter = $request.Query.tenantfilter
@@ -16,7 +16,7 @@ try {
$cmdlet = if ($request.query.state -eq "enable") { "Enable-TransportRule" } else { "Disable-TransportRule" }
$GraphRequest = New-ExoRequest -tenantid $Tenantfilter -cmdlet $cmdlet -cmdParams $params
$Result = "Set transport rule $($Request.query.guid) to $($request.query.State)"
- Log-request -API "TransportRules" -tenant $tenantfilter -message "Set transport rule $($Request.query.guid) to $($request.query.State)" -sev Debug
+ Write-LogMessage -API "TransportRules" -tenant $tenantfilter -message "Set transport rule $($Request.query.guid) to $($request.query.State)" -sev Debug
}
catch {
$ErrorMessage = Get-NormalizedError -Message $_.Exception
diff --git a/EditUser/run.ps1 b/EditUser/run.ps1
index b37270f2a804..a9251306fa89 100644
--- a/EditUser/run.ps1
+++ b/EditUser/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$userobj = $Request.body
$Results = [System.Collections.ArrayList]@()
$licenses = ($userobj | Select-Object "License_*").psobject.properties.value
@@ -46,9 +46,9 @@ try {
}
}
catch {
- Log-Request -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "User edit API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "User edit API failed. $($_.Exception.Message)" -Sev "Error"
$results.add( "Failed to edit user. $($_.Exception.Message)")
- Log-Request -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "Edited user $($userobj.displayname) with id $($userobj.Userid)" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "Edited user $($userobj.displayname) with id $($userobj.Userid)" -Sev "Info"
}
@@ -67,13 +67,13 @@ try {
Write-Host $LicenseBody
$LicRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($userobj.Userid)/assignlicense" -tenantid $Userobj.tenantid -type POST -body $LicenseBody -verbose
- Log-Request -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "Changed user $($userobj.displayname) license. Sent info: $licensebody" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "Changed user $($userobj.displayname) license. Sent info: $licensebody" -Sev "Info"
$results.add( "Success. User license has been edited." )
}
}
catch {
- Log-Request -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "License assign API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "License assign API failed. $($_.Exception.Message)" -Sev "Error"
$results.add( "We've failed to assign the license. $($_.Exception.Message)")
}
@@ -84,13 +84,13 @@ try {
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($userobj.Userid)" -tenantid $Userobj.tenantid -type "patch" -body "{`"mail`": `"$Alias`"}" -verbose
}
New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($userobj.Userid)" -tenantid $Userobj.tenantid -type "patch" -body "{`"mail`": `"$UserprincipalName`"}" -verbose
- Log-Request -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "Added Aliases to $($userobj.displayname) license $($licences)" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "Added Aliases to $($userobj.displayname) license $($licences)" -Sev "Info"
$results.add( "Success. User has been edited")
}
}
catch {
- Log-Request -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "Alias API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant ($UserObj.tenantid) -user $request.headers.'x-ms-client-principal' -message "Alias API failed. $($_.Exception.Message)" -Sev "Error"
$results.add( "Succesfully edited user. The password is $password. We've failed to create the Aliases: $($_.Exception.Message)")
}
@@ -102,12 +102,12 @@ if ($Request.body.CopyFrom -ne "") {
$groupname = (New-GraphGetRequest -tenantid $Userobj.tenantid -asApp $true -uri "https://graph.microsoft.com/beta/groups/$($_)").displayName
Write-Host "name: $groupname"
$GroupResult = New-GraphPostRequest -AsApp $true -uri "https://graph.microsoft.com/beta/groups/$($_)" -tenantid $Userobj.tenantid -type patch -body $addmemberbody -ErrorAction Stop
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Added $($UserprincipalName) to group $groupresult.displayName)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Added $($UserprincipalName) to group $groupresult.displayName)" -Sev "Info" -tenant $TenantFilter
$body = $results.add("Added group: $($groupname)")
}
catch {
$body = $results.add("We've failed to add the group $($groupname): $($_.Exception.Message)")
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Failed to add group. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($userobj.tenantid) -message "Failed to add group. $($_.Exception.Message)" -Sev "Error"
}
}
diff --git a/ExecAccessChecks/run.ps1 b/ExecAccessChecks/run.ps1
index b6c24067e4da..0cd57ccaa9b6 100644
--- a/ExecAccessChecks/run.ps1
+++ b/ExecAccessChecks/run.ps1
@@ -4,13 +4,13 @@
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
Write-Host 'PowerShell HTTP trigger function processed a request.'
if ($Request.query.Permissions -eq 'true') {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Started permissions check' -Sev 'Debug'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Started permissions check' -Sev 'Debug'
$Messages = [System.Collections.Generic.List[string]]::new()
$MissingPermissions = [System.Collections.Generic.List[string]]::new()
$Links = [System.Collections.Generic.List[object]]::new()
@@ -43,7 +43,7 @@ if ($Request.query.Permissions -eq 'true') {
Name = ''
AuthMethods = @()
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Token exception: $($_) " -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Token exception: $($_) " -Sev 'Error'
$Success = $false
}
@@ -81,7 +81,7 @@ if ($Request.query.Permissions -eq 'true') {
}
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Permissions check failed: $($_) " -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Permissions check failed: $($_) " -Sev 'Error'
$Messages.Add("We could not connect to the API to retrieve the permissions. There might be a problem with the secure application model configuration. The returned error is: $($_)") | Out-Null
$Success = $false
}
@@ -105,7 +105,7 @@ if ($Request.query.Tenants -eq 'true') {
TenantName = "$($Tenant)"
Status = 'Succesfully connected'
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message 'Tenant access check executed succesfully' -Sev 'Info'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message 'Tenant access check executed succesfully' -Sev 'Info'
}
catch {
@@ -113,7 +113,7 @@ if ($Request.query.Tenants -eq 'true') {
TenantName = "$($tenant)"
Status = "Failed to connect to $($_.Exception.Message)"
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Tenant access check failed: $($_) " -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Tenant access check failed: $($_) " -Sev 'Error'
}
@@ -133,7 +133,7 @@ if ($Request.query.Tenants -eq 'true') {
TenantName = "$($Tenant)"
Status = "Failed to connect to Exchange: $($Message)"
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Tenant access check for Exchange failed: $($Message) " -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $tenant -message "Tenant access check for Exchange failed: $($Message) " -Sev 'Error'
}
}
if (!$Tenants) { $results = 'Could not load the tenants list from cache. Please run permissions check first, or visit the tenants page.' }
diff --git a/ExecAssignApp/run.ps1 b/ExecAssignApp/run.ps1
index 63aebbf06007..3c009b9386c0 100644
--- a/ExecAssignApp/run.ps1
+++ b/ExecAssignApp/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -38,11 +38,11 @@ $AssignBody = switch ($AssignTo) {
$body = [pscustomobject]@{"Results" = "$($TenantFilter): Assigned app to $assignTo" }
try {
$GraphRequest = New-Graphpostrequest -uri "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$appFilter/assign" -tenantid $TenantFilter -body $Assignbody
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Assigned $($appFilter) to $assignTo" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Assigned $($appFilter) to $assignTo" -Sev "Info"
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to assign app $($appFilter): $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to assign app $($appFilter): $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to assign. $($_.Exception.Message)" }
}
diff --git a/ExecBECRemediate/run.ps1 b/ExecBECRemediate/run.ps1
index 6dc831c0fc2f..f70971a9d9c7 100644
--- a/ExecBECRemediate/run.ps1
+++ b/ExecBECRemediate/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Write-Host "PowerShell HTTP trigger function processed a request."
$TenantFilter = $request.body.tenantfilter
@@ -27,7 +27,7 @@ try {
}
catch {
- #Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to assign app $($appFilter): $($_.Exception.Message)" -Sev "Error"
+ #Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to assign app $($appFilter): $($_.Exception.Message)" -Sev "Error"
$results = [pscustomobject]@{"Results" = "Failed to execute remediation. $($_.Exception.Message)" }
}
diff --git a/ExecBackendURLs/run.ps1 b/ExecBackendURLs/run.ps1
index d1cfe4d94573..167353c244df 100644
--- a/ExecBackendURLs/run.ps1
+++ b/ExecBackendURLs/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Subscription = ($ENV:WEBSITE_OWNER_NAME).split('+') | Select-Object -First 1
$SWAName = $ENV:Website_SITE_NAME -replace "cipp", "CIPP-SWA-"
diff --git a/ExecConverttoSharedMailbox/run.ps1 b/ExecConverttoSharedMailbox/run.ps1
index 8953bb133390..1ec50ef7de49 100644
--- a/ExecConverttoSharedMailbox/run.ps1
+++ b/ExecConverttoSharedMailbox/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -18,10 +18,10 @@ Try {
New-ExoRequest -tenantid $TenantFilter -cmdlet "Set-mailbox" -cmdParams @{Identity = $request.query.id; type = $MailboxType }
$Results = [pscustomobject]@{"Results" = "Succesfully completed task." }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Converted mailbox $($request.query.id)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Converted mailbox $($request.query.id)" -Sev "Info"
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Convert to shared mailbox failed: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Convert to shared mailbox failed: $($_.Exception.Message)" -Sev "Error"
$Results = [pscustomobject]@{"Results" = "Failed. $_.Exception.Message" }
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
diff --git a/ExecCreateTAP/run.ps1 b/ExecCreateTAP/run.ps1
index f545f0a1deb4..97c4a20e6b4e 100644
--- a/ExecCreateTAP/run.ps1
+++ b/ExecCreateTAP/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
@@ -12,7 +12,7 @@ $Body = "{}"
try {
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($Request.query.ID)/authentication/temporaryAccessPassMethods" -tenantid $TenantFilter -type POST -body $Body -verbose
$Results = [pscustomobject]@{"Results" = "The TAP for this user is $($GraphRequest.temporaryAccessPass) - This TAP is usable for the next $($GraphRequest.LifetimeInMinutes) minutes" }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created temporary access pass for user $($Request.Query.id)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Created temporary access pass for user $($Request.Query.id)" -Sev "Info"
}
catch {
diff --git a/ExecDisableUser/run.ps1 b/ExecDisableUser/run.ps1
index f0d7a1439cce..f14b53588e17 100644
--- a/ExecDisableUser/run.ps1
+++ b/ExecDisableUser/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
diff --git a/ExecDnsConfig/run.ps1 b/ExecDnsConfig/run.ps1
index 0c4a1a0bfc2b..c90babb99e2b 100644
--- a/ExecDnsConfig/run.ps1
+++ b/ExecDnsConfig/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# List of supported resolvers
$ValidResolvers = @(
@@ -56,7 +56,7 @@ try {
}
if ($updated) {
$Config | ConvertTo-Json | Set-Content $ConfigPath
- Log-Request -API $APINAME -tenant 'Global' -user $request.headers.'x-ms-client-principal' -message 'DNS configuration updated' -Sev 'Info'
+ Write-LogMessage -API $APINAME -tenant 'Global' -user $request.headers.'x-ms-client-principal' -message 'DNS configuration updated' -Sev 'Info'
$body = [pscustomobject]@{'Results' = 'Success: DNS configuration updated.' }
}
else {
@@ -66,11 +66,11 @@ try {
}
elseif ($Request.Query.Action -eq 'GetConfig') {
$body = $Config
- Log-Request -API $APINAME -tenant 'Global' -user $request.headers.'x-ms-client-principal' -message 'Retrieved DNS configuration' -Sev 'Info'
+ Write-LogMessage -API $APINAME -tenant 'Global' -user $request.headers.'x-ms-client-principal' -message 'Retrieved DNS configuration' -Sev 'Info'
}
}
catch {
- Log-Request -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "DNS Config API failed. $($_.Exception.Message)" -Sev 'Error'
+ Write-LogMessage -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "DNS Config API failed. $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
$StatusCode = [HttpStatusCode]::BadRequest
}
diff --git a/ExecEditCalendarPermissions/run.ps1 b/ExecEditCalendarPermissions/run.ps1
index 173c7c288515..36e07e5d23b6 100644
--- a/ExecEditCalendarPermissions/run.ps1
+++ b/ExecEditCalendarPermissions/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$UserID = ($request.query.UserID)
$UserToGetPermissions = $Request.query.UserToGetPermissions
$Tenantfilter = $request.Query.tenantfilter
@@ -29,7 +29,7 @@ try {
catch {
$GraphRequest = New-ExoRequest -tenantid $Tenantfilter -cmdlet "Add-MailboxFolderPermission" -cmdParams $CalParam
}
- Log-request -API 'List Calendar Permissions' -tenant $tenantfilter -message "Calendar permissions listed for $($tenantfilter)" -sev Debug
+ Write-LogMessage -API 'List Calendar Permissions' -tenant $tenantfilter -message "Calendar permissions listed for $($tenantfilter)" -sev Debug
$Result = "Succesfully set permissions on folder $($CalParam.Identity). The user $UserToGetPermissions now has $Permissions permissions on this folder."
}
diff --git a/ExecEditMailboxPermissions/run.ps1 b/ExecEditMailboxPermissions/run.ps1
index 8ea90bc579a2..19b48950051a 100644
--- a/ExecEditMailboxPermissions/run.ps1
+++ b/ExecEditMailboxPermissions/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Accessed this API" -Sev "Debug"
$Username = $request.body.userID
$Tenantfilter = $request.body.tenantfilter
if ($username -eq $null) { exit }
@@ -16,10 +16,10 @@ foreach ($RemoveUser in $RemoveFullAccess) {
try {
$MailboxPerms = New-ExoRequest -tenantid $Tenantfilter -cmdlet "Remove-mailboxpermission" -cmdParams @{Identity = $userid; user = $RemoveUser; accessRights = @("FullAccess"); }
$results.add("Removed $($removeuser) from $($username) Shared Mailbox permissions")
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Removed $($_) from $($username) Shared Mailbox permission" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Removed $($_) from $($username) Shared Mailbox permission" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not remove mailbox permissions for $($removeuser) on $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not remove mailbox permissions for $($removeuser) on $($username)" -Sev "Error" -tenant $TenantFilter
$results.add("Could not remove shared mailbox permissions for $($username). Error: $($_.Exception.Message)")
}
}
@@ -29,11 +29,11 @@ foreach ($UserAutomap in $AddFullAccess) {
try {
$MailboxPerms = New-ExoRequest -tenantid $Tenantfilter -cmdlet "Add-MailboxPermission" -cmdParams @{Identity = $userid; user = $UserAutomap; accessRights = @("FullAccess"); automapping = $true }
$results.add( "added $($UserAutomap) to $($username) Mailbox with automapping")
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Gave full permissions to $($request.body.AccessAutomap) on $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Gave full permissions to $($request.body.AccessAutomap) on $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
$results.add( "Could not add shared mailbox permissions for $($username). Error: $($_.Exception.Message)")
}
}
@@ -43,10 +43,10 @@ foreach ($UserNoAutomap in $AddFullAccessNoAutoMap) {
try {
$MailboxPerms = New-ExoRequest -tenantid $Tenantfilter -cmdlet "Add-MailboxPermission" -cmdParams @{Identity = $userid; user = $UserNoAutomap; accessRights = @("FullAccess"); automapping = $false }
$results.add( "added $UserNoAutomap to $($username) Mailbox without automapping")
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Gave full permissions to $($request.body.AccessAutomap) on $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Gave full permissions to $($request.body.AccessAutomap) on $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
$results.add("Could not add shared mailbox permissions for $($username). Error: $($_.Exception.Message)")
}
}
@@ -57,10 +57,10 @@ foreach ($UserSendAs in $AddSendAS) {
try {
$MailboxPerms = New-ExoRequest -tenantid $Tenantfilter -cmdlet "Add-RecipientPermission" -cmdParams @{Identity = $userid; Trustee = $UserSendAs; accessRights = @("SendAs") }
$results.add( "added $AddSendAS to $($username) with Send As permissions")
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Gave sendas permissions to $($request.body.AddSendAs) on $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Gave sendas permissions to $($request.body.AddSendAs) on $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
$results.add("Could not add send-as permissions for $($username). Error: $($_.Exception.Message)")
}
}
@@ -71,10 +71,10 @@ foreach ($UserSendAs in $RemoveSendAs) {
try {
$MailboxPerms = New-ExoRequest -tenantid $Tenantfilter -cmdlet "Remove-RecipientPermission" -cmdParams @{Identity = $userid; Trustee = $UserSendAs; accessRights = @("SendAs") }
$results.add( "Removed $AddSendAS from $($username) with Send As permissions")
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Remove sendas permissions to $($request.body.AddSendAs) on $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Remove sendas permissions to $($request.body.AddSendAs) on $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not remove mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME-message "Could not remove mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
$results.add("Could not remove send-as permissions for $($username). Error: $($_.Exception.Message)")
}
}
diff --git a/ExecExcludeLicenses/run.ps1 b/ExecExcludeLicenses/run.ps1
index 13dcb63d3163..9577eb4fbd3d 100644
--- a/ExecExcludeLicenses/run.ps1
+++ b/ExecExcludeLicenses/run.ps1
@@ -4,29 +4,26 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
-Write-Host "PowerShell HTTP trigger function processed a request."
+Write-Host 'PowerShell HTTP trigger function processed a request.'
$Table = Get-CIPPTable -TableName ExcludedLicenses
try {
if ($Request.Query.List) {
- $Rows = Get-AzTableRow -Table $table
+ $Rows = Get-AzDataTableEntity @Table
if ($Rows.Count -lt 1) {
- $TableBaseData = '[{"GUID":"16ddbbfc-09ea-4de2-b1d7-312db6112d70","Product_Display_Name":"MICROSOFT TEAMS (FREE)"},{"GUID":"1f2f344a-700d-42c9-9427-5cea1d5d7ba6","Product_Display_Name":"MICROSOFT STREAM"},{"GUID":"338148b6-1b11-4102-afb9-f92b6cdc0f8d","Product_Display_Name":"DYNAMICS 365 P1 TRIAL FOR INFORMATION WORKERS"},{"GUID":"606b54a9-78d8-4298-ad8b-df6ef4481c80","Product_Display_Name":"Power Virtual Agents Viral Trial"},{"GUID":"61e6bd70-fbdb-4deb-82ea-912842f39431","Product_Display_Name":"Dynamics 365 Customer Service Insights Trial"},{"GUID":"6470687e-a428-4b7a-bef2-8a291ad947c9","Product_Display_Name":"WINDOWS STORE FOR BUSINESS"},{"GUID":"710779e8-3d4a-4c88-adb9-386c958d1fdf","Product_Display_Name":"MICROSOFT TEAMS EXPLORATORY"},{"GUID":"74fbf1bb-47c6-4796-9623-77dc7371723b","Product_Display_Name":"Microsoft Teams Trial"},{"GUID":"90d8b3f8-712e-4f7b-aa1e-62e7ae6cbe96","Product_Display_Name":"Business Apps (free)"},{"GUID":"a403ebcc-fae0-4ca2-8c8c-7a907fd6c235","Product_Display_Name":"Power BI (free)"},{"GUID":"bc946dac-7877-4271-b2f7-99d2db13cd2c","Product_Display_Name":"Dynamics 365 Customer Voice Trial"},{"GUID":"dcb1a3ae-b33f-4487-846a-a640262fadf4","Product_Display_Name":"Microsoft Power Apps Plan 2 Trial"},{"GUID":"f30db892-07e9-47e9-837c-80727f46fd3d","Product_Display_Name":"MICROSOFT FLOW FREE"},{"GUID":"fcecd1f9-a91e-488d-a918-a96cdb6ce2b0","Product_Display_Name":"Microsoft Dynamics AX7 User Trial"}]' | ConvertFrom-Json -AsHashtable -depth 10
- foreach ($Row in $TableBaseData) {
- $TableRow = @{
- table = $Table
- partitionKey = 'License'
- rowKey = $row.GUID
- property = $Row
- }
- Add-AzTableRow @TableRow | Out-Null
- $Rows = Get-AzTableRow -Table $table
+ $TableBaseData = '[{"GUID":"16ddbbfc-09ea-4de2-b1d7-312db6112d70","Product_Display_Name":"MICROSOFT TEAMS (FREE)"},{"GUID":"1f2f344a-700d-42c9-9427-5cea1d5d7ba6","Product_Display_Name":"MICROSOFT STREAM"},{"GUID":"338148b6-1b11-4102-afb9-f92b6cdc0f8d","Product_Display_Name":"DYNAMICS 365 P1 TRIAL FOR INFORMATION WORKERS"},{"GUID":"606b54a9-78d8-4298-ad8b-df6ef4481c80","Product_Display_Name":"Power Virtual Agents Viral Trial"},{"GUID":"61e6bd70-fbdb-4deb-82ea-912842f39431","Product_Display_Name":"Dynamics 365 Customer Service Insights Trial"},{"GUID":"6470687e-a428-4b7a-bef2-8a291ad947c9","Product_Display_Name":"WINDOWS STORE FOR BUSINESS"},{"GUID":"710779e8-3d4a-4c88-adb9-386c958d1fdf","Product_Display_Name":"MICROSOFT TEAMS EXPLORATORY"},{"GUID":"74fbf1bb-47c6-4796-9623-77dc7371723b","Product_Display_Name":"Microsoft Teams Trial"},{"GUID":"90d8b3f8-712e-4f7b-aa1e-62e7ae6cbe96","Product_Display_Name":"Business Apps (free)"},{"GUID":"a403ebcc-fae0-4ca2-8c8c-7a907fd6c235","Product_Display_Name":"Power BI (free)"},{"GUID":"bc946dac-7877-4271-b2f7-99d2db13cd2c","Product_Display_Name":"Dynamics 365 Customer Voice Trial"},{"GUID":"dcb1a3ae-b33f-4487-846a-a640262fadf4","Product_Display_Name":"Microsoft Power Apps Plan 2 Trial"},{"GUID":"f30db892-07e9-47e9-837c-80727f46fd3d","Product_Display_Name":"MICROSOFT FLOW FREE"},{"GUID":"fcecd1f9-a91e-488d-a918-a96cdb6ce2b0","Product_Display_Name":"Microsoft Dynamics AX7 User Trial"}]' | ConvertFrom-Json -AsHashtable -Depth 10
+ $TableRows = foreach ($Row in $TableBaseData) {
+ $Row.PartitionKey = 'License'
+ $Row.RowKey = $Row.GUID
+ $Row
}
+ Add-AzDataTableEntity @Table -Entity $TableRows -Force | Out-Null
+ $Rows = Get-AzDataTableEntity @Table
}
- Log-Request -API $APINAME -user $request.headers.'x-ms-client-principal' -message "got excluded licenses list" -Sev "Info"
+ Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message 'got excluded licenses list' -Sev 'Info'
$body = @($Rows)
}
@@ -34,35 +31,29 @@ try {
$name = $Request.Query.TenantFilter
if ($Request.Query.AddExclusion) {
$AddObject = @{
- "GUID" = $Request.body.GUID
- "Product_Display_Name" = $request.body.SKUName
+ partitionKey = 'License'
+ rowKey = $Request.body.GUID
+ 'GUID' = $Request.body.GUID
+ 'Product_Display_Name' = $request.body.SKUName
}
- $TableRow = @{
- table = $Table
- partitionKey = 'License'
- rowKey = $Request.body.GUID
- property = $AddObject
- }
- Add-AzTableRow @TableRow | Out-Null
- Log-Request -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Added exclusion $($request.body.SKUName)" -Sev "Info"
- $body = [pscustomobject]@{"Results" = "Success. We've added $($request.body.SKUName) to the excluded list." }
+ Add-AzDataTableEntity @Table -Entity $AddObject -Force | Out-Null
+ Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Added exclusion $($request.body.SKUName)" -Sev 'Info'
+ $body = [pscustomobject]@{'Results' = "Success. We've added $($request.body.SKUName) to the excluded list." }
}
if ($Request.Query.RemoveExclusion) {
- Remove-AzTableRow -Table $Table -RowKey "$($Request.Query.GUID)" -PartitionKey 'License'
- Log-Request -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Removed exclusion $($Request.Query.GUID)" -Sev "Info"
- $body = [pscustomobject]@{"Results" = "Success. We've removed $($Request.query.guid) from the excluded list." }
+ $Filter = "RowKey eq '{0}' and PartitionKey eq 'License'" -f $Request.Query.Guid
+ $Entity = Get-AzDataTableEntity @Table -Filter $Filter
+ Remove-AzDataTableEntity @Table -Entity $Entity
+ Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Removed exclusion $($Request.Query.GUID)" -Sev 'Info'
+ $body = [pscustomobject]@{'Results' = "Success. We've removed $($Request.query.guid) from the excluded list." }
}
-
-
}
catch {
- Log-Request -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Exclusion API failed. $($_.Exception.Message)" -Sev "Error"
- $body = [pscustomobject]@{"Results" = "Failed. $($_.Exception.Message)" }
+ Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "Exclusion API failed. $($_.Exception.Message)" -Sev 'Error'
+ $body = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
}
-
-
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
diff --git a/ExecExcludeTenant/run.ps1 b/ExecExcludeTenant/run.ps1
index 44900bea2dfd..ba819ae4363f 100644
--- a/ExecExcludeTenant/run.ps1
+++ b/ExecExcludeTenant/run.ps1
@@ -3,7 +3,7 @@ using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
$user = $request.headers.'x-ms-client-principal'
@@ -12,7 +12,7 @@ $date = (Get-Date).tostring('dd-MM-yyyy')
try {
if ($Request.Query.List) {
$ExcludedTenants = [System.IO.File]::ReadAllLines("ExcludedTenants") | ConvertFrom-Csv -Delimiter "|" -Header "Name", "User", "Date" | Where-Object { $_.name -ne "" }
- Log-Request -API $APINAME -user $request.headers.'x-ms-client-principal' -message "got excluded tenants list" -Sev "Info"
+ Write-LogMessage -API $APINAME -user $request.headers.'x-ms-client-principal' -message "got excluded tenants list" -Sev "Info"
$body = $ExcludedTenants
}
# Interact with query parameters or the body of the request.
@@ -23,7 +23,7 @@ try {
Add-Content -Value "$($_)|$($username)|$($date)" -Path "ExcludedTenants"
}
Remove-CIPPCache
- Log-Request -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "Added exclusion for customer(s): $($Tenants -join ",")" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "Added exclusion for customer(s): $($Tenants -join ",")" -Sev "Info"
$body = [pscustomobject]@{"Results" = "Success. Added exclusions for customer(s): $($Tenants -join ",")" }
}
@@ -32,14 +32,14 @@ try {
$Content = $Content -replace $name, ''
$Content | Set-Content -Path "ExcludedTenants"
Remove-CIPPCache
- Log-Request -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "Removed exclusion for customer $($name)" -Sev "Info"
+ Write-LogMessage -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "Removed exclusion for customer $($name)" -Sev "Info"
$body = [pscustomobject]@{"Results" = "Success. We've removed $name from the excluded tenants." }
}
}
catch {
- Log-Request -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "Exclusion API failed. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "Exclusion API failed. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed. $($_.Exception.Message)" }
}
diff --git a/ExecGraphRequest/run.ps1 b/ExecGraphRequest/run.ps1
index effe297e191a..45371004c479 100644
--- a/ExecGraphRequest/run.ps1
+++ b/ExecGraphRequest/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
Function ConvertTo-FlatObject {
# https://evotec.xyz/powershell-converting-advanced-object-to-flat-object/ - MIT License
diff --git a/ExecMaintenanceScripts/Scripts/Migrate-CippStorage.ps1 b/ExecMaintenanceScripts/Scripts/Migrate-CippStorage.ps1
index 5726a9280a71..e0a635b3c568 100644
--- a/ExecMaintenanceScripts/Scripts/Migrate-CippStorage.ps1
+++ b/ExecMaintenanceScripts/Scripts/Migrate-CippStorage.ps1
@@ -1,5 +1,5 @@
if (!(Get-Module -ListAvailable AzTable)) {
- Install-Module AzTable -Confirm:$false
+ Install-Module AzTable -Confirm:$false -Force
}
$Logo = @'
@@ -14,7 +14,6 @@ $Logo = @'
Write-Host $Logo
Write-Host '- Connecting to Azure'
Connect-AzAccount -Subscription '##SUBSCRIPTION##'
-Install-Module AzTable -Confirm:$false -Force
$RGName = '##RESOURCEGROUP##'
$FunctionApp = '##FUNCTIONAPP##'
diff --git a/ExecMaintenanceScripts/run.ps1 b/ExecMaintenanceScripts/run.ps1
index 602ebb28f8e4..0dfc6792952f 100644
--- a/ExecMaintenanceScripts/run.ps1
+++ b/ExecMaintenanceScripts/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
try {
$ReplacementStrings = @{
@@ -46,17 +46,14 @@ try {
if ($Request.Query.MakeLink) {
$Table = Get-CippTable -TableName 'MaintenanceScripts'
- $LinkGuid = (New-Guid).Guid
+ $LinkGuid = ([guid]::NewGuid()).ToString()
$MaintenanceScriptRow = @{
- 'Table' = $Table
- 'rowKey' = $LinkGuid
- 'partitionKey' = 'Maintenance'
- 'property' = @{
- 'ScriptContent' = $ScriptContent
- }
+ 'rowKey' = $LinkGuid
+ 'partitionKey' = 'Maintenance'
+ 'ScriptContent' = $ScriptContent
}
- Add-AzTableRow @MaintenanceScriptRow
+ Add-AzDataTableEntity @Table -Entity $MaintenanceScriptRow -Force
$Body = @{ Link = "/api/PublicScripts?guid=$LinkGuid" }
}
@@ -66,7 +63,7 @@ try {
}
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to retrieve maintenance scripts. Error: $($_.Exception.Message)" -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to retrieve maintenance scripts. Error: $($_.Exception.Message)" -Sev 'Error'
$Body = @{Status = "Failed to retrieve maintenance scripts $($_.Exception.Message)" }
}
diff --git a/ExecNotificationConfig/run.ps1 b/ExecNotificationConfig/run.ps1
index 0d3758961edb..862ae69095ab 100644
--- a/ExecNotificationConfig/run.ps1
+++ b/ExecNotificationConfig/run.ps1
@@ -4,43 +4,40 @@
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
-Write-Host "PowerShell HTTP trigger function processed a request."
+Write-Host 'PowerShell HTTP trigger function processed a request.'
$results = try {
$Table = Get-CIPPTable -TableName SchedulerConfig
$SchedulerConfig = @{
'tenant' = 'Any'
'tenantid' = 'TenantId'
'type' = 'CIPPNotifications'
- 'schedule' = "Every 15 minutes"
+ 'schedule' = 'Every 15 minutes'
'email' = "$($Request.Body.Email)"
'webhook' = "$($Request.Body.Webhook)"
- "removeStandard" = [boolean]$Request.Body.removeStandard
- "addStandardsDeploy" = [boolean]$Request.Body.addStandardsDeploy
- "tokenUpdater" = [boolean]$Request.Body.tokenUpdater
- "addPolicy" = [boolean]$Request.Body.addPolicy
- "removeUser" = [boolean]$Request.Body.removeUser
- "addUser" = [boolean]$Request.Body.addUser
- "addChocoApp" = [boolean]$Request.Body.addChocoApp
+ 'removeStandard' = [boolean]$Request.Body.removeStandard
+ 'addStandardsDeploy' = [boolean]$Request.Body.addStandardsDeploy
+ 'tokenUpdater' = [boolean]$Request.Body.tokenUpdater
+ 'addPolicy' = [boolean]$Request.Body.addPolicy
+ 'removeUser' = [boolean]$Request.Body.removeUser
+ 'addUser' = [boolean]$Request.Body.addUser
+ 'addChocoApp' = [boolean]$Request.Body.addChocoApp
+ partitionKey = 'CippNotifications'
+ rowKey = 'CippNotifications'
}
- $TableRow = @{
- table = $Table
- partitionKey = 'CippNotifications'
- rowKey = "CippNotifications"
- property = $SchedulerConfig
- }
- Add-AzTableRow @TableRow -UpdateExisting | Out-Null
- "succesfully set the configuration"
+
+ Add-AzDataTableEntity @Table -Entity $SchedulerConfig -Force | Out-Null
+ 'Succesfully set the configuration'
}
catch {
"Failed to set configuration: $($_.Exception.message)"
}
-$body = [pscustomobject]@{"Results" = $Results }
+$body = [pscustomobject]@{'Results' = $Results }
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
diff --git a/ExecOffboardUser/run.ps1 b/ExecOffboardUser/run.ps1
index ba496400d50e..08767f421157 100644
--- a/ExecOffboardUser/run.ps1
+++ b/ExecOffboardUser/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Username = $request.body.user
$Tenantfilter = $request.body.tenantfilter
if ($username -eq $null) { exit }
@@ -19,7 +19,7 @@ $results = switch ($request.body) {
try {
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($userid)/invalidateAllRefreshTokens" -tenantid $TenantFilter -type POST -body '{}' -verbose
"Success. All sessions by this user have been revoked"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Revoked sessions for $($userid)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Revoked sessions for $($userid)" -Sev "Info"
}
catch {
@@ -34,11 +34,11 @@ $results = switch ($request.body) {
"@
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$($userid)" -tenantid $TenantFilter -type PATCH -body $passwordProfile -verbose
"The new password is $password"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Reset the password for $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Reset the password for $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not reset password for $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not reset password for $($username)" -Sev "Error" -tenant $TenantFilter
"Could not reset password for $($username). Error: $($_.Exception.Message)"
}
@@ -50,11 +50,11 @@ $results = switch ($request.body) {
$RemoveRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups/$_/members/$($userid)/`$ref" -tenantid $tenantFilter -type DELETE -body '' -Verbose
$Groupname = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/groups/$_" -tenantid $tenantFilter).displayName
"Succesfully removed user from group $Groupname"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed groups for $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed groups for $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not remove $($username) from group $group" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not remove $($username) from group $group" -Sev "Error" -tenant $TenantFilter
"Could not remove user from group$($group): $($_.Exception.Message)"
}
@@ -66,11 +66,11 @@ $results = switch ($request.body) {
try {
$HideRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$($userid)" -tenantid $tenantFilter -type PATCH -body '{"showInAddressList": false}' -verbose
"Hidden from address list"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Hid $($username) from address list" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Hid $($username) from address list" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not hide $($username) from address list" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not hide $($username) from address list" -Sev "Error" -tenant $TenantFilter
"Could not hide $($username) from address list. Error: $($_.Exception.Message)"
}
@@ -79,11 +79,11 @@ $results = switch ($request.body) {
try {
$DisableUser = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$($userid)" -tenantid $TenantFilter -type PATCH -body '{"accountEnabled":false}' -verbose
"Disabled user account for $username"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Disabled $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Disabled $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not disable sign in for $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not disable sign in for $($username)" -Sev "Error" -tenant $TenantFilter
"Could not disable $($username). Error: $($_.Exception.Message)"
}
@@ -93,11 +93,11 @@ $results = switch ($request.body) {
try {
$SharedMailbox = New-ExoRequest -tenantid $TenantFilter -cmdlet "Set-mailbox" -cmdParams @{Identity = $userid; type = "Shared" }
"Converted $($username) to Shared Mailbox"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Converted $($username) to a shared mailbox" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Converted $($username) to a shared mailbox" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not convert $username to shared mailbox" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not convert $username to shared mailbox" -Sev "Error" -tenant $TenantFilter
"Could not convert $($username) to a shared mailbox. Error: $($_.Exception.Message)"
}
}
@@ -116,11 +116,11 @@ $results = switch ($request.body) {
'X-Requested-With' = 'XMLHttpRequest'
}
"Users Onedrive url is $UserSharepoint. Access has been given to $($request.body.onedriveaccess)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Gave $($Request.body.onedriveaccess) access to $($username) onedrive" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Gave $($Request.body.onedriveaccess) access to $($username) onedrive" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add new owner to Onedrive $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add new owner to Onedrive $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
"Could not add owner to Onedrive for $($username). Error: $($_.Exception.Message)"
}
@@ -129,11 +129,11 @@ $results = switch ($request.body) {
try {
$permissions = New-ExoRequest -tenantid $TenantFilter -cmdlet "Add-MailboxPermission" -cmdParams @{Identity = $userid; user = $Request.body.AccessNoAutomap; automapping = $false; accessRights = @("FullAccess"); InheritanceType = "all" }
"added $($Request.body.AccessNoAutomap) to $($username) Shared Mailbox without automapping"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Gave full permissions to $($request.body.AccessNoAutomap) on $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Gave full permissions to $($request.body.AccessNoAutomap) on $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
"Could not add shared mailbox permissions with no auto-mapping for $($username). Error: $($_.Exception.Message)"
}
@@ -142,11 +142,11 @@ $results = switch ($request.body) {
try {
$permissions = New-ExoRequest -tenantid $TenantFilter -cmdlet "Add-MailboxPermission" -cmdParams @{Identity = $userid; user = $Request.body.AccessAutomap; automapping = $true; accessRights = @("FullAccess"); InheritanceType = "all" }
"added $($Request.body.AccessAutomap) to $($username) Shared Mailbox with automapping"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Gave full permissions to $($request.body.AccessAutomap) on $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Gave full permissions to $($request.body.AccessAutomap) on $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add mailbox permissions for $($request.body.AccessAutomap) on $($username)" -Sev "Error" -tenant $TenantFilter
"Could not add shared mailbox permissions with automapping for $($username). Error: $($_.Exception.Message)"
}
@@ -156,11 +156,11 @@ $results = switch ($request.body) {
try {
$permissions = New-ExoRequest -tenantid $TenantFilter -cmdlet "Set-MailboxAutoReplyConfiguration" -cmdParams @{Identity = $userid; AutoReplyState = "Enabled"; InternalMessage = $_."OOO"; ExternalMessage = $_."OOO" }
"added Out-of-office to $username"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Set Out-of-office for $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Set Out-of-office for $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add OOO for $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add OOO for $($username)" -Sev "Error" -tenant $TenantFilter
"Could not add out of office message for $($username). Error: $($_.Exception.Message)"
}
@@ -169,11 +169,11 @@ $results = switch ($request.body) {
try {
$permissions = New-ExoRequest -tenantid $TenantFilter -cmdlet "Set-mailbox" -cmdParams @{Identity = $userid; ForwardingAddress = $_.forward ; DeliverToMailboxAndForward = $true }
"Forwarding all email for $username to $($_.Forward)"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Set Forwarding for $($username) to $($_.Forward)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Set Forwarding for $($username) to $($_.Forward)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add forwarding for $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not add forwarding for $($username)" -Sev "Error" -tenant $TenantFilter
"Could not add forwarding for $($username). Error: $($_.Exception.Message)"
}
@@ -185,11 +185,11 @@ $results = switch ($request.body) {
$LicenseBody = '{"addLicenses": [], "removeLicenses": ' + $LicensesToRemove + '}'
$LicRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($userid)/assignlicense" -tenantid $tenantFilter -type POST -body $LicenseBody -verbose
"Removed current licenses: $(($ConvertTable | Where-Object { $_.guid -in $CurrentLicenses }).'Product_Display_Name' -join ',')"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed all licenses for $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed all licenses for $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not remove licenses for $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not remove licenses for $($username)" -Sev "Error" -tenant $TenantFilter
"Could not remove licenses for $($username). Error: $($_.Exception.Message)"
}
@@ -199,11 +199,11 @@ $results = switch ($request.body) {
try {
$DeleteRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($userid)" -type DELETE -tenant $TenantFilter
"Deleted the user account"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted account $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted account $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete $($username)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete $($username)" -Sev "Error" -tenant $TenantFilter
"Could not delete $($username). Error: $($_.Exception.Message)"
}
}
@@ -221,11 +221,11 @@ $results = switch ($request.body) {
}
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted Rules for $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted Rules for $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete rules for $($username): $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete rules for $($username): $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
"Could not delete rules for $($username). Error: $($_.Exception.Message)"
}
}
@@ -243,11 +243,11 @@ $results = switch ($request.body) {
}
}
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted mobile devices for $($username)" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted mobile devices for $($username)" -Sev "Info" -tenant $TenantFilter
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete mobile devices for $($username): $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete mobile devices for $($username): $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
"Could not delete mobile devices for $($username). Error: $($_.Exception.Message)"
}
}
diff --git a/ExecQuarantineManagement/run.ps1 b/ExecQuarantineManagement/run.ps1
index c0575385d2f4..63fce55d98e9 100644
--- a/ExecQuarantineManagement/run.ps1
+++ b/ExecQuarantineManagement/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -23,10 +23,10 @@ Try {
Write-Host $params
New-ExoRequest -tenantid $TenantFilter -cmdlet "Release-QuarantineMessage" -cmdParams $Params
$Results = [pscustomobject]@{"Results" = "Succesfully completed task." }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "$($request.query.id)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "$($request.query.id)" -Sev "Info"
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Quarantine Management failed: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Quarantine Management failed: $($_.Exception.Message)" -Sev "Error"
$Results = [pscustomobject]@{"Results" = "Failed. $($_.Exception.Message)" }
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
diff --git a/ExecResetMFA/run.ps1 b/ExecResetMFA/run.ps1
index ecd8c312e57b..4dfbf6c4da6d 100644
--- a/ExecResetMFA/run.ps1
+++ b/ExecResetMFA/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -26,11 +26,11 @@ try {
$SetMFA = (Invoke-RestMethod -Uri "https://provisioningapi.microsoftonline.com/provisioningwebservice.svc" -Method post -Body $MSOLXML -ContentType 'application/soap+xml; charset=utf-8')
$Results = [pscustomobject]@{"Results" = "Successfully completed request. User must supply MFA at next logon" }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Reset Multi factor authentication settings for $($Request.query.id)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Reset Multi factor authentication settings for $($Request.query.id)" -Sev "Info"
}
catch {
$Results = [pscustomobject]@{"Results" = "Failed to reset MFA methods for $($Request.query.id): $($_.Exception.Message)" }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to reset MFA: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to reset MFA: $($_.Exception.Message)" -Sev "Error"
}
diff --git a/ExecResetPass/run.ps1 b/ExecResetPass/run.ps1
index d509d01c222d..07e758c966d5 100644
--- a/ExecResetPass/run.ps1
+++ b/ExecResetPass/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -28,11 +28,11 @@ try {
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/users/$($Request.query.ID)" -tenantid $TenantFilter -type PATCH -body $passwordProfile -verbose
}
$Results = [pscustomobject]@{"Results" = "Successfully completed request. User must changed password at next logon is set to $mustChange. Temporary password is $password" }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Reset password for $($REquest.query.id)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Reset password for $($REquest.query.id)" -Sev "Info"
}
catch {
$Results = [pscustomobject]@{"Results" = "Failed to reset password for $($Request.query.id): $($_.Exception.Message)" }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to reset password for $($Request.query.id): $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to reset password for $($Request.query.id): $($_.Exception.Message)" -Sev "Error"
}
diff --git a/ExecRestoreDeleted/run.ps1 b/ExecRestoreDeleted/run.ps1
index ccf529e20052..3ebea4012d78 100644
--- a/ExecRestoreDeleted/run.ps1
+++ b/ExecRestoreDeleted/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
diff --git a/ExecRevokeSessions/run.ps1 b/ExecRevokeSessions/run.ps1
index ac22e4585fb8..bb06176ba478 100644
--- a/ExecRevokeSessions/run.ps1
+++ b/ExecRevokeSessions/run.ps1
@@ -4,14 +4,14 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
try {
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($Request.query.ID)/invalidateAllRefreshTokens" -tenantid $TenantFilter -type POST -body '{}' -verbose
$Results = [pscustomobject]@{"Results" = "Success. All sessions by this user have been revoked" }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Revoked sessions for $($Request.Query.id)" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Revoked sessions for $($Request.Query.id)" -Sev "Info"
}
catch {
diff --git a/ExecSAMSetup/run.ps1 b/ExecSAMSetup/run.ps1
index 69678714d7ad..021b7ef8306b 100644
--- a/ExecSAMSetup/run.ps1
+++ b/ExecSAMSetup/run.ps1
@@ -12,7 +12,7 @@ if ("admin" -notin $UserCreds.userRoles) {
}
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
if ($env:MSI_SECRET) {
Disable-AzContextAutosave -Scope Process | Out-Null
$AzSession = Connect-AzAccount -Identity
diff --git a/ExecSendPush/run.ps1 b/ExecSendPush/run.ps1
index 7095dd6f2963..3e90ec703308 100644
--- a/ExecSendPush/run.ps1
+++ b/ExecSendPush/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$TenantFilter = $Request.Query.TenantFilter
$UserEmail = $Request.Query.UserEmail
@@ -108,7 +108,7 @@ if ($ClientToken) {
}
$Results = [pscustomobject]@{"Results" = $Body }
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Sent push request to $UserEmail - Result: $($obj.BeginTwoWayAuthenticationResponse.result.value | Out-String)" -Sev "Info"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Sent push request to $UserEmail - Result: $($obj.BeginTwoWayAuthenticationResponse.result.value | Out-String)" -Sev "Info"
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
diff --git a/ExecSetSecurityAlert/run.ps1 b/ExecSetSecurityAlert/run.ps1
index 001ccfb107b7..f6b9b7fcd5e0 100644
--- a/ExecSetSecurityAlert/run.ps1
+++ b/ExecSetSecurityAlert/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$tenantfilter = $Request.Query.TenantFilter
@@ -13,12 +13,12 @@ $Status = $Request.Query.Status
$AssignBody = '{"status":"' + $Status + '","vendorInformation":{"provider":"' + $Request.query.provider + '","vendor":"' + $Request.query.vendor + '"}}'
try {
$GraphRequest = New-Graphpostrequest -uri "https://graph.microsoft.com/beta/security/alerts/$AlertFilter" -type PATCH -tenantid $TenantFilter -body $Assignbody -asApp $true
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Set alert $AlertFilter to status $Status" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Set alert $AlertFilter to status $Status" -Sev "Info"
$body = [pscustomobject]@{"Results" = "Set status for alert to $Status" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to update alert $($AlertFilter): $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to update alert $($AlertFilter): $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to change status: $($_.Exception.Message)" }
}
diff --git a/ExecSetSecurityIncident/run.ps1 b/ExecSetSecurityIncident/run.ps1
index c564327b80e3..d12d10cc8df9 100644
--- a/ExecSetSecurityIncident/run.ps1
+++ b/ExecSetSecurityIncident/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$first=''
# Interact with query parameters or the body of the request.
@@ -58,17 +58,17 @@ try {
$ResponseBody = [pscustomobject]@{"Results" = $BodyBuild }
New-Graphpostrequest -uri "https://graph.microsoft.com/beta/security/incidents/$IncidentFilter" -type PATCH -tenantid $TenantFilter -body $Assignbody -asApp $true
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Update incident $IncidentFilter with values $Assignbody" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Update incident $IncidentFilter with values $Assignbody" -Sev "Info"
}
else {
$ResponseBody = [pscustomobject]@{"Results" = "Cannot update redirected incident" }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Refuse to pdate incident $IncidentFilter with values $Assignbody because it is redirected to another incident" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Refuse to pdate incident $IncidentFilter with values $Assignbody because it is redirected to another incident" -Sev "Info"
}
$body = $ResponseBody
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to update alert $($AlertFilter): $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed to update alert $($AlertFilter): $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to update incident: $($_.Exception.Message)" }
}
diff --git a/GetDashboard/run.ps1 b/GetDashboard/run.ps1
index 53f2196eac8c..3d0d77a86923 100644
--- a/GetDashboard/run.ps1
+++ b/GetDashboard/run.ps1
@@ -17,7 +17,7 @@ Function Test-CronRange {
#>
[cmdletbinding()]
param(
- [ValidatePattern("^[\d-*/,]*$")]
+ [ValidatePattern('^[\d-*/,]*$')]
[string]$range
,
[int]$inputvalue
@@ -54,8 +54,8 @@ Function ConvertFrom-DateTable {
Param (
$DateTable
)
- $datestring = "{0}-{1:00}-{2:00} {3:00}:{4:00}" -f $DateTable.year, $DateTable.month, $DateTable.day, $DateTable.hour, $DateTable.Minute
- $date = [datetime]::ParseExact($datestring, "yyyy-MM-dd HH:mm", $null)
+ $datestring = '{0}-{1:00}-{2:00} {3:00}:{4:00}' -f $DateTable.year, $DateTable.month, $DateTable.day, $DateTable.hour, $DateTable.Minute
+ $date = [datetime]::ParseExact($datestring, 'yyyy-MM-dd HH:mm', $null)
return $date
}
Function Invoke-CronIncrement {
@@ -173,7 +173,7 @@ Function Get-CronNextExecutionTime {
$next = Invoke-CronIncrement -DateTable $Next -Increment Day
$next.Hour = 0
$next.Minute = 0
- } While ( (Test-CronRange -InputValue $Next.WeekDay -Range $cronWeekday) -eq $false )
+ } While ( (Test-CronRange -InputValue $Next.WeekDay -Range $cronWeekday) -eq $false )
continue
}
$done = $true
@@ -186,40 +186,32 @@ Function Get-CronNextExecutionTime {
Return $Date
}
-$context = New-AzStorageContext -ConnectionString $ENV:AzureWebJobsStorage
-$tablename = 'CippLogs'
-try {
- $StorageTable = Get-AzStorageTable –Context $context -Name $tablename -ErrorAction Stop
-}
-catch {
- New-AzStorageTable -Context $context -Name $tablename | Out-Null
- $StorageTable = Get-AzStorageTable –Context $context -Name $tablename
-}
-$Table = $StorageTable.CloudTable
+$Table = Get-CippTable -tablename CippLogs
$PartitionKey = Get-Date -UFormat '%Y%m%d'
-$Rows = Get-AzTableRow -Table $table -PartitionKey $PartitionKey -Top 10 -SelectColumn Tenant, Message
+$Filter = "PartitionKey eq '{0}'" -f $PartitionKey
+$Rows = Get-AzDataTableEntity @Table -PartitionKey $PartitionKey | Sort-Object TableTimestamp -Descending | Select-Object -Top 10
$SlimRows = New-Object System.Collections.ArrayList
foreach ($Row in $Rows) {
$SlimRows.Add(@{
- Tenant = $Row.Tenant
- Message = $Row.Message
- })
+ Tenant = $Row.Tenant
+ Message = $Row.Message
+ })
}
$Alerts = [System.Collections.ArrayList]@()
-if ($ENV:ApplicationID -eq "LongApplicationID" -or $null -eq $ENV:ApplicationID) { $Alerts.add("You have not yet setup your SAM Setup. Please go to the SAM Wizard in settings to finish setup") }
-if ($ENV:FUNCTIONS_EXTENSION_VERSION -ne "~4") { $Alerts.add("Your Function App is running on a Runtime version lower than 4. This impacts performance. Go to Settings -> Backend -> Function App Configuration -> Function Runtime Settings and set this to 4 for maximum performance") }
-if ($psversiontable.psversion.toString() -lt 7.2) { $Alerts.add("Your Function App is running on Powershell 7. This impacts performance. Go to Settings -> Backend -> Function App Configuration -> General Settings and set PowerShell Core Version to 7.2 for maximum performance") }
+if ($ENV:ApplicationID -eq 'LongApplicationID' -or $null -eq $ENV:ApplicationID) { $Alerts.add('You have not yet setup your SAM Setup. Please go to the SAM Wizard in settings to finish setup') }
+if ($ENV:FUNCTIONS_EXTENSION_VERSION -ne '~4') { $Alerts.add('Your Function App is running on a Runtime version lower than 4. This impacts performance. Go to Settings -> Backend -> Function App Configuration -> Function Runtime Settings and set this to 4 for maximum performance') }
+if ($psversiontable.psversion.toString() -lt 7.2) { $Alerts.add('Your Function App is running on Powershell 7. This impacts performance. Go to Settings -> Backend -> Function App Configuration -> General Settings and set PowerShell Core Version to 7.2 for maximum performance') }
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$dash = [PSCustomObject]@{
NextStandardsRun = (Get-CronNextExecutionTime -Expression '0 */3 * * *').tostring('s')
NextBPARun = (Get-CronNextExecutionTime -Expression '0 3 * * *').tostring('s')
queuedApps = [int64](Get-ChildItem '.\ChocoApps.Cache' -ErrorAction SilentlyContinue).count
queuedStandards = [int64](Get-ChildItem '.\Cache_Standards' -ErrorAction SilentlyContinue).count
tenantCount = [int64](Get-Content '.\tenants.cache.json' | ConvertFrom-Json -ErrorAction SilentlyContinue).count
- RefreshTokenDate = (Get-CronNextExecutionTime -Expression '0 0 * * 0').AddDays('-7').tostring('s') -split "T" | Select-Object -First 1
- ExchangeTokenDate = (Get-CronNextExecutionTime -Expression '0 0 * * 0').AddDays('-7').tostring('s') -split "T" | Select-Object -First 1
+ RefreshTokenDate = (Get-CronNextExecutionTime -Expression '0 0 * * 0').AddDays('-7').tostring('s') -split 'T' | Select-Object -First 1
+ ExchangeTokenDate = (Get-CronNextExecutionTime -Expression '0 0 * * 0').AddDays('-7').tostring('s') -split 'T' | Select-Object -First 1
LastLog = @($SlimRows)
Alerts = @($Alerts)
}
diff --git a/GetVersion/run.ps1 b/GetVersion/run.ps1
index 299e18778586..001928ca7104 100644
--- a/GetVersion/run.ps1
+++ b/GetVersion/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$APIVersion = Get-Content "version_latest.txt" | Out-String
$CIPPVersion = $request.query.localversion
diff --git a/GraphHelper.psm1 b/GraphHelper.psm1
index 393dde2ea1b0..fde7b7b8aea5 100644
--- a/GraphHelper.psm1
+++ b/GraphHelper.psm1
@@ -3,15 +3,21 @@ function Get-CIPPTable {
param (
$tablename = 'CippLogs'
)
- $context = New-AzStorageContext -ConnectionString $ENV:AzureWebJobsStorage
- try {
- $StorageTable = Get-AzStorageTable -Context $context -Name $tablename -ErrorAction Stop
+ #$context = New-AzStorageContext -ConnectionString $ENV:AzureWebJobsStorage
+ #try {
+ # $StorageTable = Get-AzStorageTable -Context $context -Name $tablename -ErrorAction Stop
+ #}
+ #catch {
+ # New-AzStorageTable -Context $context -Name $tablename | Out-Null
+ # $StorageTable = Get-AzStorageTable -Context $context -Name $tablename
+ #}
+ #return $StorageTable.CloudTable
+
+ @{
+ ConnectionString = $ENV:AzureWebJobsStorage
+ TableName = $tablename
+ CreateTableIfNotExists = $true
}
- catch {
- New-AzStorageTable -Context $context -Name $tablename | Out-Null
- $StorageTable = Get-AzStorageTable -Context $context -Name $tablename
- }
- return $StorageTable.CloudTable
}
function Get-NormalizedError {
[CmdletBinding()]
@@ -64,33 +70,29 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $refreshToken, $Retur
return $header
}
-function Log-Request ($message, $tenant = "None", $API = "None", $user, $sev) {
+function Write-LogMessage ($message, $tenant = 'None', $API = 'None', $user, $sev) {
$username = ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($user)) | ConvertFrom-Json).userDetails
- $Table = Get-CIPPTable
- if (!$tenant) { $tenant = "None" }
+ $Table = Get-CIPPTable -tablename CippLogs
+
+ if (!$tenant) { $tenant = 'None' }
if (!$username) { $username = 'CIPP' }
if ($sev -eq 'Debug' -and $env:DebugMode -ne 'true') {
Write-Information 'Not writing to log file - Debug mode is not enabled.'
return
}
- $PartitionKey = Get-Date -UFormat '%Y%m%d'
- $LogRequest = @{
- 'Tenant' = $tenant
- 'API' = $API
- 'Message' = $message
- 'Username' = $username
- 'Severity' = $sev
- 'SentAsAlert' = $false
- }
+ $PartitionKey = (Get-Date -UFormat '%Y%m%d').ToString()
$TableRow = @{
- table = $Table
- partitionKey = $PartitionKey
- rowKey = [guid]::NewGuid()
- property = $LogRequest
- }
- Add-AzTableRow @TableRow | Out-Null
-
+ 'Tenant' = $tenant
+ 'API' = $API
+ 'Message' = $message
+ 'Username' = $username
+ 'Severity' = $sev
+ 'SentAsAlert' = $false
+ 'PartitionKey' = $PartitionKey
+ 'RowKey' = ([guid]::NewGuid()).ToString()
+ }
+ Add-AzDataTableEntity @Table -Entity $TableRow | Out-Null
}
function New-GraphGetRequest ($uri, $tenantid, $scope, $AsApp, $noPagination) {
diff --git a/ListAPDevices/run.ps1 b/ListAPDevices/run.ps1
index 9233a971a68d..7139f25c8c34 100644
--- a/ListAPDevices/run.ps1
+++ b/ListAPDevices/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListAlertsQueue/run.ps1 b/ListAlertsQueue/run.ps1
index 3e0efa340971..a938ed668282 100644
--- a/ListAlertsQueue/run.ps1
+++ b/ListAlertsQueue/run.ps1
@@ -4,13 +4,14 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
Write-Host 'PowerShell HTTP trigger function processed a request.'
$Table = Get-CIPPTable -TableName 'SchedulerConfig'
-$QueuedApps = Get-AzTableRow -Table $Table -PartitionKey 'Alert'
+$Filter = "PartitionKey eq 'Alert'"
+$QueuedApps = Get-AzDataTableEntity @Table -Filter $Filter
$CurrentStandards = foreach ($QueueFile in $QueuedApps) {
[PSCustomObject]@{
diff --git a/ListAllTenantDeviceCompliance/run.ps1 b/ListAllTenantDeviceCompliance/run.ps1
index c75c0d9d6c92..74e737422da7 100644
--- a/ListAllTenantDeviceCompliance/run.ps1
+++ b/ListAllTenantDeviceCompliance/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListAppStatus/run.ps1 b/ListAppStatus/run.ps1
index 6efd88101365..4788e37b468d 100644
--- a/ListAppStatus/run.ps1
+++ b/ListAppStatus/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListApplicationQueue/run.ps1 b/ListApplicationQueue/run.ps1
index 6c69d8e8f2a6..c5058f2f645a 100644
--- a/ListApplicationQueue/run.ps1
+++ b/ListApplicationQueue/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListApps/run.ps1 b/ListApps/run.ps1
index 5a6c8780a165..8291fa283489 100644
--- a/ListApps/run.ps1
+++ b/ListApps/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListAppsRepository/run.ps1 b/ListAppsRepository/run.ps1
index e180b792db57..46f346164939 100644
--- a/ListAppsRepository/run.ps1
+++ b/ListAppsRepository/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$Search = $Request.Query.Search
$Repository = $Request.Query.Repository
diff --git a/ListAutopilotconfig/run.ps1 b/ListAutopilotconfig/run.ps1
index 2cd272df0702..11042abf346d 100644
--- a/ListAutopilotconfig/run.ps1
+++ b/ListAutopilotconfig/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListAzureADConnectStatus/run.ps1 b/ListAzureADConnectStatus/run.ps1
index 517ebecc5f08..d618510eb3c2 100644
--- a/ListAzureADConnectStatus/run.ps1
+++ b/ListAzureADConnectStatus/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListBasicAuth/run.ps1 b/ListBasicAuth/run.ps1
index c7284981c5b0..2dfefa29cabc 100644
--- a/ListBasicAuth/run.ps1
+++ b/ListBasicAuth/run.ps1
@@ -6,7 +6,7 @@ $APIName = $TriggerMetadata.FunctionName
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
$currentTime = Get-Date -Format "yyyy-MM-ddTHH:MM:ss"
@@ -17,7 +17,7 @@ $filters = "createdDateTime ge $($endTime)Z and createdDateTime lt $($currentTim
try {
$GraphRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/auditLogs/signIns?api-version=beta&filter=$($filters)" -tenantid $TenantFilter -erroraction stop | Select-Object userPrincipalName, clientAppUsed | Sort-Object -Unique -Property clientAppUsed
$response = $GraphRequest
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Retrieved basic authentication report" -Sev "Debug" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Retrieved basic authentication report" -Sev "Debug" -tenant $TenantFilter
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
@@ -26,7 +26,7 @@ try {
})
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to retrieve basic authentication report: $($_.Exception.message) " -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to retrieve basic authentication report: $($_.Exception.message) " -Sev "Error" -tenant $TenantFilter
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = '500'
diff --git a/ListCAtemplates/run.ps1 b/ListCAtemplates/run.ps1
index b785b8d8d6db..d3b2af37f1f8 100644
--- a/ListCAtemplates/run.ps1
+++ b/ListCAtemplates/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListCalendarPermissions/run.ps1 b/ListCalendarPermissions/run.ps1
index ba36ea74ef2e..cf68c653e4ab 100644
--- a/ListCalendarPermissions/run.ps1
+++ b/ListCalendarPermissions/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$UserID = $request.Query.UserID
$Tenantfilter = $request.Query.tenantfilter
@@ -13,7 +13,7 @@ try {
$CalendarFolder = New-ExoRequest -tenantid $Tenantfilter -cmdlet "Get-MailboxFolderStatistics" -cmdParams $GetCalParam | Select-Object -First 1
$CalParam = @{Identity = "$($UserID):\$($CalendarFolder.name)" }
$GraphRequest = New-ExoRequest -tenantid $Tenantfilter -cmdlet "Get-MailboxFolderPermission" -cmdParams $CalParam | Select-Object Identity, User, AccessRights, FolderName
- Log-request -API 'List Calendar Permissions' -tenant $tenantfilter -message "Calendar permissions listed for $($tenantfilter)" -sev Debug
+ Write-LogMessage -API 'List Calendar Permissions' -tenant $tenantfilter -message "Calendar permissions listed for $($tenantfilter)" -sev Debug
$StatusCode = [HttpStatusCode]::OK
}
catch {
diff --git a/ListConditionalAccessPolicies/run.ps1 b/ListConditionalAccessPolicies/run.ps1
index e0052b95f774..a14f71181e1d 100644
--- a/ListConditionalAccessPolicies/run.ps1
+++ b/ListConditionalAccessPolicies/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
function Get-LocationNameFromId {
diff --git a/ListContacts/run.ps1 b/ListContacts/run.ps1
index 6a4277de30db..c2d300b0b410 100644
--- a/ListContacts/run.ps1
+++ b/ListContacts/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$selectlist = "id", "companyName", "displayName", "mail", "onPremisesSyncEnabled", "editURL"
diff --git a/ListDefenderState/run.ps1 b/ListDefenderState/run.ps1
index 1bb13b06966d..81d7779dcba4 100644
--- a/ListDefenderState/run.ps1
+++ b/ListDefenderState/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$StatusCode = [HttpStatusCode]::OK
# Write to the Azure Functions log stream.
diff --git a/ListDeletedItems/run.ps1 b/ListDeletedItems/run.ps1
index dfbf22de2963..a90b359d42a2 100644
--- a/ListDeletedItems/run.ps1
+++ b/ListDeletedItems/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$selectlist = "id", "accountEnabled", "businessPhones", "city", "createdDateTime", "companyName", "country", "department", "displayName", "faxNumber", "givenName", "isResourceAccount", "jobTitle", "mail", "mailNickname", "mobilePhone", "onPremisesDistinguishedName", "officeLocation", "onPremisesLastSyncDateTime", "otherMails", "postalCode", "preferredDataLocation", "preferredLanguage", "proxyAddresses", "showInAddressList", "state", "streetAddress", "surname", "usageLocation", "userPrincipalName", "userType", "assignedLicenses", "onPremisesSyncEnabled", "LicJoined", "Aliases", "primDomain"
diff --git a/ListDevices/run.ps1 b/ListDevices/run.ps1
index f06692c71935..4198d435381c 100644
--- a/ListDevices/run.ps1
+++ b/ListDevices/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListDomainHealth/run.ps1 b/ListDomainHealth/run.ps1
index 4752e6fc3d1b..d82ef06c9e62 100644
--- a/ListDomainHealth/run.ps1
+++ b/ListDomainHealth/run.ps1
@@ -8,7 +8,7 @@ Import-Module .\DNSHelper.psm1
$UserCreds = ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($request.headers.'x-ms-client-principal')) | ConvertFrom-Json)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
Write-Host 'PowerShell HTTP trigger function processed a request.'
@@ -18,13 +18,8 @@ try {
if ($Request.Query.Action) {
if ($Request.Query.Domain -match '^(((?!-))(xn--|_{1,1})?[a-z0-9-]{0,61}[a-z0-9]{1,1}\.)*(xn--)?([a-z0-9][a-z0-9\-]{0,60}|[a-z0-9-]{1,30}\.[a-z]{2,})$') {
$DomainTable = Get-CIPPTable -Table 'Domains'
- $DomainQuery = @{
- Table = $DomainTable
- ColumnName = 'RowKey'
- Value = $Request.Query.Domain
- Operator = 'Equal'
- }
- $DomainInfo = Get-AzTableRow @DomainQuery
+ $Filter = "RowKey eq '{0}'" -f $Request.Query.Domain
+ $DomainInfo = Get-AzDataTableEntity @DomainTable -Filter $Filter
switch ($Request.Query.Action) {
'ReadSpfRecord' {
$SpfQuery = @{
@@ -52,8 +47,22 @@ try {
$DkimQuery.Selectors = ($Request.Query.Selector).trim() -split '\s*,\s*'
if ('admin' -in $UserCreds.userRoles -or 'editor' -in $UserCreds.userRoles) {
- $DomainInfo.DkimSelectors = ($DkimQuery.Selectors | ConvertTo-Json)
- $DomainInfo | Update-AzTableRow -Table $DomainTable
+ $DkimSelectors = ($DkimQuery.Selectors | ConvertTo-Json -Compress)
+ if ($DomainInfo) {
+ $DomainInfo.DkimSelectors = $DkimSelectors
+ }
+ else {
+ $DomainInfo = @{
+ 'RowKey' = $Request.Query.Domain
+ 'PartitionKey' = 'ManualEntry'
+ 'TenantId' = 'NoTenant'
+ 'MailProviders' = ''
+ 'TenantDetails' = ''
+ 'DomainAnalyser' = ''
+ 'DkimSelectors' = $DkimSelectors
+ }
+ }
+ Add-AzDataTableEntity @DomainTable -Entity $DomainInfo -Force
}
}
elseif (![string]::IsNullOrEmpty($DomainInfo.DkimSelectors)) {
@@ -101,7 +110,7 @@ try {
}
}
catch {
- Log-Request -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "DNS Helper API failed. $($_.Exception.Message)" -Sev 'Error'
+ Write-LogMessage -API $APINAME -tenant $($name) -user $request.headers.'x-ms-client-principal' -message "DNS Helper API failed. $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
$StatusCode = [HttpStatusCode]::BadRequest
}
diff --git a/ListDomainTests/run.ps1 b/ListDomainTests/run.ps1
index 2e187203b9f6..82a9d53fdcb5 100644
--- a/ListDomainTests/run.ps1
+++ b/ListDomainTests/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
@@ -72,7 +72,7 @@ try {
}
}
catch {
- Log-Request -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "SPF Record Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "SPF Record Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
}
try {
@@ -94,7 +94,7 @@ try {
}
}
catch {
- Log-Request -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "DMARC Policy Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "DMARC Policy Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
}
try {
@@ -116,7 +116,7 @@ try {
}
}
catch {
- Log-Request -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "MX Record Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "MX Record Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
}
try {
@@ -138,7 +138,7 @@ try {
}
}
catch {
- Log-Request -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "DNSSEC Record Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "DNSSEC Record Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
}
try {
@@ -160,7 +160,7 @@ try {
}
}
catch {
- Log-Request -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "DKIM Record Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -API $APINAME -tenant "CIPP" -user $request.headers.'x-ms-client-principal' -message "DKIM Record Lookup Failed for $($DomainToCheck). $($_.Exception.Message)" -Sev "Error"
}
Write-Host "$DomainToCheck was checked with results:`nSPF Fails: $($FinalObject.SPFResults.ValidationFails)`nSPF Passes: $($FinalObject.SPFResults.ValidationPasses)`nSPF Warns: $($FinalObject.SPFResults.ValidationWarns) "
diff --git a/ListDomains/run.ps1 b/ListDomains/run.ps1
index e7d9e264f862..fafe94ee47a8 100644
--- a/ListDomains/run.ps1
+++ b/ListDomains/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListGroups/run.ps1 b/ListGroups/run.ps1
index 28c74a25300d..d5a30fafb11c 100644
--- a/ListGroups/run.ps1
+++ b/ListGroups/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListIntunePolicy/run.ps1 b/ListIntunePolicy/run.ps1
index c1ba17939c76..2c8ec72d8afb 100644
--- a/ListIntunePolicy/run.ps1
+++ b/ListIntunePolicy/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListIntuneTemplates/run.ps1 b/ListIntuneTemplates/run.ps1
index 54abd2a3f5e4..03aeffa417a2 100644
--- a/ListIntuneTemplates/run.ps1
+++ b/ListIntuneTemplates/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListLicenses/run.ps1 b/ListLicenses/run.ps1
index 61d4ea3df481..76d4a94bdb64 100644
--- a/ListLicenses/run.ps1
+++ b/ListLicenses/run.ps1
@@ -4,16 +4,16 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
-Write-Host "PowerShell HTTP trigger function processed a request."
+Write-Host 'PowerShell HTTP trigger function processed a request.'
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
-$RawGraphRequest = if ($TenantFilter -ne "AllTenants") {
- $LicRequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/subscribedSkus" -tenantid $TenantFilter
+$RawGraphRequest = if ($TenantFilter -ne 'AllTenants') {
+ $LicRequest = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $TenantFilter
[PSCustomObject]@{
Tenant = $TenantFilter
Licenses = $LicRequest
@@ -21,12 +21,12 @@ $RawGraphRequest = if ($TenantFilter -ne "AllTenants") {
}
else {
$Table = Get-CIPPTable -TableName cachelicenses
- $Rows = Get-AzTableRow -Table $table | Where-Object -Property TableTimestamp -GT (Get-Date).AddHours(-1)
+ $Rows = Get-AzDataTableEntity @Table | Where-Object -Property Timestamp -GT (Get-Date).AddHours(-1)
if (!$Rows) {
Push-OutputBinding -Name Msg -Value (Get-Date).ToString()
[PSCustomObject]@{
- Tenant = "Loading data for all tenants. Please check back in 1 minute"
- Licenses = "Loading data for all tenants. Please check back in 1 minute"
+ Tenant = 'Loading data for all tenants. Please check back in 1 minute'
+ Licenses = 'Loading data for all tenants. Please check back in 1 minute'
}
}
else {
diff --git a/ListLicensesAllTenants/run.ps1 b/ListLicensesAllTenants/run.ps1
index d2d30afdc679..38114e4e3466 100644
--- a/ListLicensesAllTenants/run.ps1
+++ b/ListLicensesAllTenants/run.ps1
@@ -11,10 +11,10 @@ Write-Host "Pop receipt: $($TriggerMetadata.PopReceipt)"
Write-Host "Dequeue count: $($TriggerMetadata.DequeueCount)"
-$RawGraphRequest = Get-Tenants | ForEach-Object -parallel {
+$RawGraphRequest = Get-Tenants | ForEach-Object -Parallel {
Import-Module '.\GraphHelper.psm1'
try {
- $Licrequest = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/subscribedSkus" -tenantid $_.defaultDomainName -ErrorAction Stop
+ $Licrequest = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $_.defaultDomainName -ErrorAction Stop
[PSCustomObject]@{
Tenant = $_.defaultDomainName
Licenses = $Licrequest
@@ -23,7 +23,7 @@ $RawGraphRequest = Get-Tenants | ForEach-Object -parallel {
catch {
[PSCustomObject]@{
Tenant = $_.defaultDomainName
- Licenses = "Could not retrieve licenses"
+ Licenses = 'Could not retrieve licenses'
}
}
}
@@ -44,17 +44,10 @@ $GraphRequest = foreach ($singlereq in $RawGraphRequest) {
skuId = $sku.skuId
skuPartNumber = $PrettyName
availableUnits = $sku.prepaidUnits.enabled - $sku.consumedUnits
+ partitionKey = 'License'
+ rowKey = "$($Request.tenant)-$($Request.skuId)"
}
}
}
$Table = Get-CIPPTable -TableName cachelicenses
-
-foreach ($Request in $GraphRequest) {
- $TableRow = @{
- table = $Table
- partitionKey = 'License'
- rowKey = "$($Request.tenant)-$($Request.skuId)"
- property = $Request
- }
- Add-AzTableRow @TableRow -UpdateExisting | Out-Null
-}
\ No newline at end of file
+Add-AzDataTableEntity @Table -Entity $GraphRequest -Force | Out-Null
diff --git a/ListLogs/run.ps1 b/ListLogs/run.ps1
index 4dbeaa95ecbd..a3e16a134bde 100644
--- a/ListLogs/run.ps1
+++ b/ListLogs/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Info'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Info'
if ($request.Query.Filter -eq 'True') {
$LogLevel = if ($Request.query.Severity) { ($Request.query.Severity).split(',') } else { 'Info', 'Warn', 'Error', 'Critical', 'Alert' }
@@ -20,7 +20,7 @@ $Table = Get-CIPPTable
$ReturnedLog = if ($Request.Query.ListLogs) {
- Get-AzTableRow -Table $table | Sort-Object -Unique partitionkey | ForEach-Object {
+ Get-AzDataTableEntity @Table | Sort-Object -Unique partitionkey | Select-Object partitionkey | ForEach-Object {
@{
value = $_.PartitionKey
label = $_.PartitionKey
@@ -28,10 +28,11 @@ $ReturnedLog = if ($Request.Query.ListLogs) {
}
}
else {
- $Rows = Get-AzTableRow -Table $table -PartitionKey $PartitionKey | Where-Object { $_.Severity -In $LogLevel -and $_.user -like $username }
+ $Filter = "PartitionKey eq '{0}'" -f $PartitionKey
+ $Rows = Get-AzDataTableEntity @Table -Filter $Filter | Where-Object { $_.Severity -In $LogLevel -and $_.user -like $username }
foreach ($Row in $Rows) {
@{
- DateTime = $Row.TableTimeStamp
+ DateTime = $Row.Timestamp
Tenant = $Row.Tenant
API = $Row.API
Message = $Row.Message
diff --git a/ListMFAUsers/run.ps1 b/ListMFAUsers/run.ps1
index 83d013928798..5a000ec5d7bd 100644
--- a/ListMFAUsers/run.ps1
+++ b/ListMFAUsers/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
diff --git a/ListMailQuarantine/run.ps1 b/ListMailQuarantine/run.ps1
index 96667a6c4a9a..2d558ddb3776 100644
--- a/ListMailQuarantine/run.ps1
+++ b/ListMailQuarantine/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Tenantfilter = $request.Query.tenantfilter
try {
diff --git a/ListMailboxCAS/run.ps1 b/ListMailboxCAS/run.ps1
index 389331b3def0..60d0b4d145db 100644
--- a/ListMailboxCAS/run.ps1
+++ b/ListMailboxCAS/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListMailboxMobileDevices/run.ps1 b/ListMailboxMobileDevices/run.ps1
index 1649458f2aa2..57ad47cf1212 100644
--- a/ListMailboxMobileDevices/run.ps1
+++ b/ListMailboxMobileDevices/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListMailboxStatistics/run.ps1 b/ListMailboxStatistics/run.ps1
index 5075569e8bcc..df448c509559 100644
--- a/ListMailboxStatistics/run.ps1
+++ b/ListMailboxStatistics/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListMailboxes/run.ps1 b/ListMailboxes/run.ps1
index bebd197f7e9a..85111b75389b 100644
--- a/ListMailboxes/run.ps1
+++ b/ListMailboxes/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListMessageTrace/run.ps1 b/ListMessageTrace/run.ps1
index b91c18982b09..6aae3ba30afa 100644
--- a/ListMessageTrace/run.ps1
+++ b/ListMessageTrace/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
try {
@@ -23,12 +23,12 @@ try {
}
else {
New-ExoRequest -tenantid $Tenantfilter -cmdlet "Get-MessageTrace" -cmdParams $Searchparams | Select-Object MessageTraceId, Status, Subject, RecipientAddress, SenderAddress, @{ Name = 'Date'; Expression = { $_.Received.tostring('s') } }
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Executed message trace" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Executed message trace" -Sev "Info"
}
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed executing messagetrace. Error: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($tenantfilter) -message "Failed executing messagetrace. Error: $($_.Exception.Message)" -Sev "Error"
$trace = @{Status = "Failed to retrieve message trace $($_.Exception.Message)" }
}
diff --git a/ListNotificationConfig/run.ps1 b/ListNotificationConfig/run.ps1
index ecee260a0057..11091d202ff9 100644
--- a/ListNotificationConfig/run.ps1
+++ b/ListNotificationConfig/run.ps1
@@ -4,10 +4,11 @@
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$Table = Get-CIPPTable -TableName SchedulerConfig
-$Config = Get-AzTableRow -Table $table -RowKey "CippNotifications" -PartitionKey 'CippNotifications'
+$Filter = "RowKey eq 'CippNotifications' and PartitionKey eq 'CippNotifications'"
+$Config = Get-AzDataTableEntity @Table -Filter $Filter
$body = $Config
diff --git a/ListOAuthApps/run.ps1 b/ListOAuthApps/run.ps1
index b1f16f95a7d6..4c1daa0f60c5 100644
--- a/ListOAuthApps/run.ps1
+++ b/ListOAuthApps/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListPhishPolicies/run.ps1 b/ListPhishPolicies/run.ps1
index 2905b4952b90..3d9dff6712ab 100644
--- a/ListPhishPolicies/run.ps1
+++ b/ListPhishPolicies/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListRoles/run.ps1 b/ListRoles/run.ps1
index 89228d57dd66..7641edca5c6e 100644
--- a/ListRoles/run.ps1
+++ b/ListRoles/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListServiceHealth/run.ps1 b/ListServiceHealth/run.ps1
index c4bc6bfe398f..c55a2e5bc751 100644
--- a/ListServiceHealth/run.ps1
+++ b/ListServiceHealth/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
diff --git a/ListSharedMailboxStatistics/run.ps1 b/ListSharedMailboxStatistics/run.ps1
index 6f672b509c3f..fb4c19680a47 100644
--- a/ListSharedMailboxStatistics/run.ps1
+++ b/ListSharedMailboxStatistics/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListSharepointSettings/run.ps1 b/ListSharepointSettings/run.ps1
index 0ad4d28bcd96..a50213b067e2 100644
--- a/ListSharepointSettings/run.ps1
+++ b/ListSharepointSettings/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListSites/run.ps1 b/ListSites/run.ps1
index 103b608da5d0..181d9c257c21 100644
--- a/ListSites/run.ps1
+++ b/ListSites/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListStandards/run.ps1 b/ListStandards/run.ps1
index 02b571588794..836b3cd25375 100644
--- a/ListStandards/run.ps1
+++ b/ListStandards/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListTeams/run.ps1 b/ListTeams/run.ps1
index 0fe73d46a7e8..2acf5160bdd5 100644
--- a/ListTeams/run.ps1
+++ b/ListTeams/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListTeamsActivity/run.ps1 b/ListTeamsActivity/run.ps1
index 20f261a97eb5..88246bffcf8c 100644
--- a/ListTeamsActivity/run.ps1
+++ b/ListTeamsActivity/run.ps1
@@ -2,7 +2,7 @@ using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
diff --git a/ListTeamsVoice/run.ps1 b/ListTeamsVoice/run.ps1
index fafe57b8376c..00e894cd3abc 100644
--- a/ListTeamsVoice/run.ps1
+++ b/ListTeamsVoice/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListTenants/run.ps1 b/ListTenants/run.ps1
index 0248233b5ff1..02b40d9e1e83 100644
--- a/ListTenants/run.ps1
+++ b/ListTenants/run.ps1
@@ -5,7 +5,7 @@ param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Clear Cache
@@ -42,10 +42,10 @@ try {
}
- Log-Request -user $request.headers.'x-ms-client-principal' -tenant $Tenantfilter -API $APINAME -message 'Listed Tenant Details' -Sev 'Debug'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -tenant $Tenantfilter -API $APINAME -message 'Listed Tenant Details' -Sev 'Debug'
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -tenant $Tenantfilter -API $APINAME -message "List Tenant failed. The error is: $($_.Exception.Message)" -Sev 'Error'
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -tenant $Tenantfilter -API $APINAME -message "List Tenant failed. The error is: $($_.Exception.Message)" -Sev 'Error'
$body = [pscustomobject]@{'Results' = "Failed to retrieve tenants: $($_.Exception.Message)" }
}
diff --git a/ListTransportRules/run.ps1 b/ListTransportRules/run.ps1
index c3950b98ebc5..4bdbab41b2ca 100644
--- a/ListTransportRules/run.ps1
+++ b/ListTransportRules/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Tenantfilter = $request.Query.tenantfilter
try {
diff --git a/ListTransportRulesTemplates/run.ps1 b/ListTransportRulesTemplates/run.ps1
index 922e91fecb54..a2d7e6541515 100644
--- a/ListTransportRulesTemplates/run.ps1
+++ b/ListTransportRulesTemplates/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListUserConditionalAccessPolicies/run.ps1 b/ListUserConditionalAccessPolicies/run.ps1
index f0f808dbb35a..d84419daff67 100644
--- a/ListUserConditionalAccessPolicies/run.ps1
+++ b/ListUserConditionalAccessPolicies/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListUserDevices/run.ps1 b/ListUserDevices/run.ps1
index 7fabe9b5700e..c31bb6a92c6b 100644
--- a/ListUserDevices/run.ps1
+++ b/ListUserDevices/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListUserGroups/run.ps1 b/ListUserGroups/run.ps1
index 728a6b8dda3d..6a97be613f40 100644
--- a/ListUserGroups/run.ps1
+++ b/ListUserGroups/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListUserMailboxDetails/run.ps1 b/ListUserMailboxDetails/run.ps1
index adbdee68622b..3efb932d84f6 100644
--- a/ListUserMailboxDetails/run.ps1
+++ b/ListUserMailboxDetails/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListUserSigninLogs/run.ps1 b/ListUserSigninLogs/run.ps1
index 73bde9cc5985..22074c4f865c 100644
--- a/ListUserSigninLogs/run.ps1
+++ b/ListUserSigninLogs/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/ListUsers/run.ps1 b/ListUsers/run.ps1
index 495fd9e1edce..8260b87cb2be 100644
--- a/ListUsers/run.ps1
+++ b/ListUsers/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$selectlist = "id", "accountEnabled", "businessPhones", "city", "createdDateTime", "companyName", "country", "department", "displayName", "faxNumber", "givenName", "isResourceAccount", "jobTitle", "mail", "mailNickname", "mobilePhone", "onPremisesDistinguishedName", "officeLocation", "onPremisesLastSyncDateTime", "otherMails", "postalCode", "preferredDataLocation", "preferredLanguage", "proxyAddresses", "showInAddressList", "state", "streetAddress", "surname", "usageLocation", "userPrincipalName", "userType", "assignedLicenses", "onPremisesSyncEnabled", "LicJoined", "Aliases", "primDomain"
diff --git a/ListmailboxPermissions/run.ps1 b/ListmailboxPermissions/run.ps1
index 9ec5afceb4e9..5256457c6a79 100644
--- a/ListmailboxPermissions/run.ps1
+++ b/ListmailboxPermissions/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
diff --git a/Modules/AzBobbyTables/2.2.0/AzBobbyTables.PS.dll b/Modules/AzBobbyTables/2.2.0/AzBobbyTables.PS.dll
new file mode 100644
index 000000000000..e90825d7fe93
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/AzBobbyTables.PS.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/AzBobbyTables.PS.pdb b/Modules/AzBobbyTables/2.2.0/AzBobbyTables.PS.pdb
new file mode 100644
index 000000000000..836f0b95b13e
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/AzBobbyTables.PS.pdb differ
diff --git a/Modules/AzBobbyTables/2.2.0/AzBobbyTables.psd1 b/Modules/AzBobbyTables/2.2.0/AzBobbyTables.psd1
new file mode 100644
index 000000000000..f980276bba70
--- /dev/null
+++ b/Modules/AzBobbyTables/2.2.0/AzBobbyTables.psd1
@@ -0,0 +1,124 @@
+@{
+
+# Script module or binary module file associated with this manifest.
+RootModule = 'AzBobbyTables.PS.dll'
+
+# Version number of this module.
+ModuleVersion = '2.2.0'
+
+# Supported PSEditions
+CompatiblePSEditions = @('Core')
+
+# ID used to uniquely identify this module
+GUID = 'eead4f42-5080-4f83-8901-340c529a5a11'
+
+# Author of this module
+Author = 'Emanuel Palm'
+
+# Company or vendor of this module
+CompanyName = 'pipe.how'
+
+# Copyright statement for this module
+Copyright = '(c) Emanuel Palm. All rights reserved.'
+
+# Description of the functionality provided by this module
+Description = 'A module that wraps the Azure Data Tables SDK.'
+
+# Minimum version of the PowerShell engine required by this module
+PowerShellVersion = '7.0'
+
+# Name of the PowerShell host required by this module
+# PowerShellHostName = ''
+
+# Minimum version of the PowerShell host required by this module
+# PowerShellHostVersion = ''
+
+# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+# DotNetFrameworkVersion = ''
+
+# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+# ClrVersion = ''
+
+# Processor architecture (None, X86, Amd64) required by this module
+# ProcessorArchitecture = ''
+
+# Modules that must be imported into the global environment prior to importing this module
+# RequiredModules = @()
+
+# Assemblies that must be loaded prior to importing this module
+# RequiredAssemblies = @()
+
+# Script files (.ps1) that are run in the caller's environment prior to importing this module.
+# ScriptsToProcess = @()
+
+# Type files (.ps1xml) to be loaded when importing this module
+# TypesToProcess = @()
+
+# Format files (.ps1xml) to be loaded when importing this module
+# FormatsToProcess = @()
+
+# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+# NestedModules = @()
+
+# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+FunctionsToExport = @()
+
+# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+CmdletsToExport = @('Add-AzDataTableEntity', 'Get-AzDataTableEntity', 'Remove-AzDataTableEntity', 'Update-AzDataTableEntity')
+
+# Variables to export from this module
+VariablesToExport = @()
+
+# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+AliasesToExport = @('Add-AzDataTableRow', 'Get-AzDataTableRow', 'Remove-AzDataTableRow', 'Update-AzDataTableRow')
+
+# DSC resources to export from this module
+# DscResourcesToExport = @()
+
+# List of all modules packaged with this module
+# ModuleList = @()
+
+# List of all files packaged with this module
+# FileList = @()
+
+# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+PrivateData = @{
+
+ PSData = @{
+
+ # Tags applied to this module. These help with module discovery in online galleries.
+ Tags = @('azure', 'storage', 'table')
+
+ # A URL to the license for this module.
+ LicenseUri = 'https://github.com/PalmEmanuel/AzBobbyTables/blob/main/LICENSE'
+
+ # A URL to the main website for this project.
+ ProjectUri = 'https://github.com/PalmEmanuel/AzBobbyTables'
+
+ # A URL to an icon representing this module.
+ # IconUri = ''
+
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
+
+ # Prerelease string of this module
+ # Prerelease = ''
+
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
+
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
+
+ } # End of PSData hashtable
+
+} # End of PrivateData hashtable
+
+# HelpInfo URI of this module
+# HelpInfoURI = ''
+
+# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+# DefaultCommandPrefix = ''
+
+}
+
diff --git a/Modules/AzBobbyTables/2.2.0/PSGetModuleInfo.xml b/Modules/AzBobbyTables/2.2.0/PSGetModuleInfo.xml
new file mode 100644
index 000000000000..f4f54ed4b561
--- /dev/null
+++ b/Modules/AzBobbyTables/2.2.0/PSGetModuleInfo.xml
@@ -0,0 +1,129 @@
+
+
+
+ Microsoft.PowerShell.Commands.PSRepositoryItemInfo
+ System.Management.Automation.PSCustomObject
+ System.Object
+
+
+ AzBobbyTables
+ 2.2.0
+ Module
+ A module that wraps the Azure Data Tables SDK.
+ Emanuel Palm
+ PalmEmanuel
+ (c) Emanuel Palm. All rights reserved.
+ 2022-07-18T20:54:52-04:00
+
+
+ https://github.com/PalmEmanuel/AzBobbyTables/blob/main/LICENSE
+ https://github.com/PalmEmanuel/AzBobbyTables
+
+
+
+ System.Object[]
+ System.Array
+ System.Object
+
+
+ azure
+ storage
+ table
+ PSModule
+ PSEdition_Core
+
+
+
+
+ System.Collections.Hashtable
+ System.Object
+
+
+
+ Workflow
+
+
+
+
+
+
+ Cmdlet
+
+
+
+ Add-AzDataTableEntity
+ Get-AzDataTableEntity
+ Remove-AzDataTableEntity
+ Update-AzDataTableEntity
+
+
+
+
+ RoleCapability
+
+
+
+ Function
+
+
+
+ DscResource
+
+
+
+ Command
+
+
+
+ Add-AzDataTableEntity
+ Get-AzDataTableEntity
+ Remove-AzDataTableEntity
+ Update-AzDataTableEntity
+
+
+
+
+
+
+
+
+
+
+
+ https://www.powershellgallery.com/api/v2
+ PSGallery
+ NuGet
+
+
+ System.Management.Automation.PSCustomObject
+ System.Object
+
+
+ (c) Emanuel Palm. All rights reserved.
+ A module that wraps the Azure Data Tables SDK.
+ False
+ True
+ True
+ 9
+ 161
+ 613496
+ 7/18/2022 8:54:52 PM -04:00
+ 7/18/2022 8:54:52 PM -04:00
+ 7/19/2022 9:35:57 AM -04:00
+ azure storage table PSModule PSEdition_Core PSCmdlet_Add-AzDataTableEntity PSCommand_Add-AzDataTableEntity PSCmdlet_Get-AzDataTableEntity PSCommand_Get-AzDataTableEntity PSCmdlet_Remove-AzDataTableEntity PSCommand_Remove-AzDataTableEntity PSCmdlet_Update-AzDataTableEntity PSCommand_Update-AzDataTableEntity PSIncludes_Cmdlet
+ False
+ 2022-07-19T09:35:57Z
+ 2.2.0
+ Emanuel Palm
+ false
+ Module
+ AzBobbyTables.nuspec|dependencies\System.Numerics.Vectors.dll|dependencies\System.Text.Encodings.Web.dll|dependencies\System.Threading.Tasks.Extensions.dll|AzBobbyTables.psd1|dependencies\Azure.Core.dll|dependencies\System.Buffers.dll|dependencies\System.Memory.Data.dll|dependencies\System.Runtime.CompilerServices.Unsafe.dll|dependencies\System.Text.Json.dll|en-US\AzBobbyTables.PS.dll-Help.xml|AzBobbyTables.PS.dll|dependencies\AzBobbyTables.Core.dll|dependencies\Azure.Data.Tables.dll|dependencies\System.Diagnostics.DiagnosticSource.dll|dependencies\System.Memory.dll|AzBobbyTables.PS.pdb|dependencies\AzBobbyTables.Core.pdb|dependencies\Microsoft.Bcl.AsyncInterfaces.dll
+ eead4f42-5080-4f83-8901-340c529a5a11
+ 7.0
+ pipe.how
+
+
+ C:\Users\jduprey.CNS\Documents\GitHub\CIPP-API\Modules\AzBobbyTables\2.2.0
+
+
+
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/AzBobbyTables.Core.dll b/Modules/AzBobbyTables/2.2.0/dependencies/AzBobbyTables.Core.dll
new file mode 100644
index 000000000000..1ccba9f6556c
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/AzBobbyTables.Core.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/AzBobbyTables.Core.pdb b/Modules/AzBobbyTables/2.2.0/dependencies/AzBobbyTables.Core.pdb
new file mode 100644
index 000000000000..326877d2db63
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/AzBobbyTables.Core.pdb differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/Azure.Core.dll b/Modules/AzBobbyTables/2.2.0/dependencies/Azure.Core.dll
new file mode 100644
index 000000000000..8e5bf0f38ef6
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/Azure.Core.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/Azure.Data.Tables.dll b/Modules/AzBobbyTables/2.2.0/dependencies/Azure.Data.Tables.dll
new file mode 100644
index 000000000000..a98e30abd756
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/Azure.Data.Tables.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/Microsoft.Bcl.AsyncInterfaces.dll b/Modules/AzBobbyTables/2.2.0/dependencies/Microsoft.Bcl.AsyncInterfaces.dll
new file mode 100644
index 000000000000..f2955edfecb7
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/Microsoft.Bcl.AsyncInterfaces.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Buffers.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Buffers.dll
new file mode 100644
index 000000000000..c0970c078522
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Buffers.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Diagnostics.DiagnosticSource.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Diagnostics.DiagnosticSource.dll
new file mode 100644
index 000000000000..a2b54fb042de
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Diagnostics.DiagnosticSource.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Memory.Data.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Memory.Data.dll
new file mode 100644
index 000000000000..6f2a3e0ad07f
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Memory.Data.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Memory.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Memory.dll
new file mode 100644
index 000000000000..953a9d2e3926
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Memory.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Numerics.Vectors.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Numerics.Vectors.dll
new file mode 100644
index 000000000000..10205772c39d
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Numerics.Vectors.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Runtime.CompilerServices.Unsafe.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Runtime.CompilerServices.Unsafe.dll
new file mode 100644
index 000000000000..02d9849738f2
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Runtime.CompilerServices.Unsafe.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Text.Encodings.Web.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Text.Encodings.Web.dll
new file mode 100644
index 000000000000..a4d360553c9d
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Text.Encodings.Web.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Text.Json.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Text.Json.dll
new file mode 100644
index 000000000000..fe2154a3bf3a
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Text.Json.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/dependencies/System.Threading.Tasks.Extensions.dll b/Modules/AzBobbyTables/2.2.0/dependencies/System.Threading.Tasks.Extensions.dll
new file mode 100644
index 000000000000..dfab23478ab4
Binary files /dev/null and b/Modules/AzBobbyTables/2.2.0/dependencies/System.Threading.Tasks.Extensions.dll differ
diff --git a/Modules/AzBobbyTables/2.2.0/en-US/AzBobbyTables.PS.dll-Help.xml b/Modules/AzBobbyTables/2.2.0/en-US/AzBobbyTables.PS.dll-Help.xml
new file mode 100644
index 000000000000..8413b296e1ed
--- /dev/null
+++ b/Modules/AzBobbyTables/2.2.0/en-US/AzBobbyTables.PS.dll-Help.xml
@@ -0,0 +1,1245 @@
+
+
+
+
+ Add-AzDataTableEntity
+ Add
+ AzDataTableEntity
+
+ Add one or more entities to an Azure Table.
+
+
+
+ Add one or more entities to an Azure Table, provided as hashtables.
+
+
+
+ Add-AzDataTableEntity
+
+ ConnectionString
+
+ The connection string to the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ Entity
+
+ The entities to add to the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ Force
+
+ Overwrites provided entities if they exist. The same as running the command Update-AzDataTableEntity.
+
+
+ SwitchParameter
+
+
+ False
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ {{ Fill CreateTableIfNotExists Description }}
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+ Add-AzDataTableEntity
+
+ Entity
+
+ The entities to add to the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ Force
+
+ Overwrites provided entities if they exist. The same as running the command Update-AzDataTableEntity.
+
+
+ SwitchParameter
+
+
+ False
+
+
+ SharedAccessSignature
+
+ The table service SAS URL. The table endpoint of the storage account, with the shared access token appended to it.
+
+ Uri
+
+ Uri
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ {{ Fill CreateTableIfNotExists Description }}
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+ Add-AzDataTableEntity
+
+ Entity
+
+ The entities to add to the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ Force
+
+ Overwrites provided entities if they exist. The same as running the command Update-AzDataTableEntity.
+
+
+ SwitchParameter
+
+
+ False
+
+
+ StorageAccountKey
+
+ The storage account access key.
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountName
+
+ The name of the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ {{ Fill CreateTableIfNotExists Description }}
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+
+
+ ConnectionString
+
+ The connection string to the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ Entity
+
+ The entities to add to the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ Force
+
+ Overwrites provided entities if they exist. The same as running the command Update-AzDataTableEntity.
+
+ SwitchParameter
+
+ SwitchParameter
+
+
+ False
+
+
+ SharedAccessSignature
+
+ The table service SAS URL. The table endpoint of the storage account, with the shared access token appended to it.
+
+ Uri
+
+ Uri
+
+
+ None
+
+
+ StorageAccountKey
+
+ The storage account access key.
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountName
+
+ The name of the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ {{ Fill CreateTableIfNotExists Description }}
+
+ SwitchParameter
+
+ SwitchParameter
+
+
+ False
+
+
+
+
+
+ System.Collections.Hashtable[]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -------------------------- Example 1 --------------------------
+ PS C:\> $User = @{ FirstName = 'Bobby'; LastName = 'Tables'; PartitionKey = 'Example'; RowKey = '1' }
+PS C:\> Add-AzDataTableEntity -Entity $User -TableName $TableName -SharedAccessSignature $SAS
+
+ Add the user "Bobby Tables" to a table using a shared access signature URL.
+
+
+
+ -------------------------- Example 2 --------------------------
+ PS C:\> $Users = @(
+>> @{ FirstName = 'Bobby'; LastName = 'Tables'; PartitionKey = 'Example'; RowKey = '1' },
+>> @{ FirstName = 'Bobby Junior'; LastName = 'Tables'; PartitionKey = 'Example'; RowKey = '2' } )
+PS C:\> Add-AzDataTableEntity -Entity $Users -TableName $TableName -ConnectionString $ConnectionString -Force
+
+ Add multiple users to a table using a connection string, overwriting any existing rows.
+
+
+
+
+
+
+
+ Get-AzDataTableEntity
+ Get
+ AzDataTableEntity
+
+ Get one or more entities from an Azure Table.
+
+
+
+ Get either all entities from an Azure Table, or those matching a provided OData filter.
+ Documentation on querying tables and entities: https://docs.microsoft.com/en-gb/rest/api/storageservices/querying-tables-and-entities
+
+
+
+ Get-AzDataTableEntity
+
+ ConnectionString
+
+ The connection string to the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ Filter
+
+ The OData filter to use in the query. Documentation on querying tables and entities: https://docs.microsoft.com/en-gb/rest/api/storageservices/querying-tables-and-entities
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+ Get-AzDataTableEntity
+
+ Filter
+
+ The OData filter to use in the query. Documentation on querying tables and entities: https://docs.microsoft.com/en-gb/rest/api/storageservices/querying-tables-and-entities
+
+ String
+
+ String
+
+
+ None
+
+
+ SharedAccessSignature
+
+ The table service SAS URL. The table endpoint of the storage account, with the shared access token token appended to it.
+
+ Uri
+
+ Uri
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+ Get-AzDataTableEntity
+
+ Filter
+
+ The OData filter to use in the query. Documentation on querying tables and entities: https://docs.microsoft.com/en-gb/rest/api/storageservices/querying-tables-and-entities
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountKey
+
+ The storage account access key.
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountName
+
+ The name of the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+
+
+ ConnectionString
+
+ The connection string to the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ Filter
+
+ The OData filter to use in the query. Documentation on querying tables and entities: https://docs.microsoft.com/en-gb/rest/api/storageservices/querying-tables-and-entities
+
+ String
+
+ String
+
+
+ None
+
+
+ SharedAccessSignature
+
+ The table service SAS URL. The table endpoint of the storage account, with the shared access token token appended to it.
+
+ Uri
+
+ Uri
+
+
+ None
+
+
+ StorageAccountKey
+
+ The storage account access key.
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountName
+
+ The name of the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+ SwitchParameter
+
+ SwitchParameter
+
+
+ False
+
+
+
+
+
+ System.String
+
+
+
+
+
+
+
+
+
+ System.Collections.Hashtable[]
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -------------------------- Example 1 --------------------------
+ PS C:\> $UserEntity = Get-AzDataTableEntity -Filter "FirstName eq 'Bobby' and LastName eq 'Tables'" -TableName $TableName -ConnectionString $ConnectionString
+
+ Get the user "Bobby Tables" from the table using a connection string.
+
+
+
+
+
+
+
+ Remove-AzDataTableEntity
+ Remove
+ AzDataTableEntity
+
+ Remove one or more entities from an Azure Table.
+
+
+
+ Remove one or more entities from an Azure Table, based on PartitionKey and RowKey.
+
+
+
+ Remove-AzDataTableEntity
+
+ ConnectionString
+
+ The connection string to the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ Entity
+
+ The entities to remove from the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+ Remove-AzDataTableEntity
+
+ Entity
+
+ The entities to remove from the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ SharedAccessSignature
+
+ The table service SAS URL. The table endpoint of the storage account, with the shared access token token appended to it.
+
+ Uri
+
+ Uri
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+ Remove-AzDataTableEntity
+
+ Entity
+
+ The entities to remove from the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ StorageAccountKey
+
+ The storage account access key.
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountName
+
+ The name of the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+
+
+ ConnectionString
+
+ The connection string to the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ Entity
+
+ The entities to remove from the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ SharedAccessSignature
+
+ The table service SAS URL. The table endpoint of the storage account, with the shared access token token appended to it.
+
+ Uri
+
+ Uri
+
+
+ None
+
+
+ StorageAccountKey
+
+ The storage account access key.
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountName
+
+ The name of the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+ SwitchParameter
+
+ SwitchParameter
+
+
+ False
+
+
+
+
+
+ System.Collections.Hashtable[]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -------------------------- Example 1 --------------------------
+ PS C:\> $Entity = @{ PartitionKey = 'Example'; RowKey = '1' }
+PS C:\> Remove-AzDataTableEntity -Entity $Entity -TableName $TableName -StorageAccountName $Name -StorageAccountKey $Key
+
+ Remove the entity with PartitionKey "Example" and RowKey "1", using the storage account name and an access key.
+
+
+
+ -------------------------- Example 2 --------------------------
+ PS C:\> $UserEntity = Get-AzDataTableEntity -Filter "FirstName eq 'Bobby' and LastName eq 'Tables'" -TableName $TableName -ConnectionString $ConnectionString
+PS C:\> Remove-AzDataTableEntity -Entity $UserEntity -TableName $TableName -StorageAccountName $Name -StorageAccountKey $Key
+
+ Get the user "Bobby Tables" from the table using a connection string, then remove the user using the storage account name and an access key.
+
+
+
+ -------------------------- Example 3 --------------------------
+ PS C:\> $Users = Get-AzDataTableEntity -Filter "LastName eq 'Tables'" -TableName $TableName -ConnectionString $ConnectionString
+PS C:\> Remove-AzDataTableEntity -Entity $Users -TableName $TableName -StorageAccountName $Name -StorageAccountKey $Key
+
+ Gets all users with the last name "Tables" from the table using a connection string, then removes the users using the storage account name and an access key.
+
+
+
+
+
+
+
+ Update-AzDataTableEntity
+ Update
+ AzDataTableEntity
+
+ Update one or more entities in an Azure Table.
+
+
+
+ Update one or more entities already existing in an Azure Table. For adding and overwriting, also see the command Add-AzDataTableEntity.
+ The PartitionKey and RowKey cannot be updated.
+
+
+
+ Update-AzDataTableEntity
+
+ ConnectionString
+
+ The connection string to the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ Entity
+
+ The entities to update in the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+ Update-AzDataTableEntity
+
+ Entity
+
+ The entities to update in the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ SharedAccessSignature
+
+ The table service SAS URL. The table endpoint of the storage account, with the shared access token token appended to it.
+
+ Uri
+
+ Uri
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+ Update-AzDataTableEntity
+
+ Entity
+
+ The entities to update in the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ StorageAccountKey
+
+ The storage account access key.
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountName
+
+ The name of the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+
+ SwitchParameter
+
+
+ False
+
+
+
+
+
+ ConnectionString
+
+ The connection string to the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ Entity
+
+ The entities to update in the table.
+
+ Hashtable[]
+
+ Hashtable[]
+
+
+ None
+
+
+ SharedAccessSignature
+
+ The table service SAS URL. The table endpoint of the storage account, with the shared access token token appended to it.
+
+ Uri
+
+ Uri
+
+
+ None
+
+
+ StorageAccountKey
+
+ The storage account access key.
+
+ String
+
+ String
+
+
+ None
+
+
+ StorageAccountName
+
+ The name of the storage account.
+
+ String
+
+ String
+
+
+ None
+
+
+ TableName
+
+ The name of the table.
+
+ String
+
+ String
+
+
+ None
+
+
+ CreateTableIfNotExists
+
+ If the table should be created if it does not exist.
+
+ SwitchParameter
+
+ SwitchParameter
+
+
+ False
+
+
+
+
+
+ System.Collections.Hashtable[]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -------------------------- Example 1 --------------------------
+ PS C:\> $UserEntity = Get-AzDataTableEntity -Filter "FirstName eq 'Bobby'" -TableName $TableName -ConnectionString $ConnectionString
+PS C:\> $UserEntity['LastName'] = 'Tables'
+PS C:\> Update-AzDataTableEntity -Entity $UserEntity -TableName $TableName -ConnectionString $ConnectionString
+
+ Update the last name of the user "Bobby" to "Tables" using a connection string.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Modules/AzTable/2.1.0/AzTable.psd1 b/Modules/AzTable/2.1.0/AzTable.psd1
deleted file mode 100644
index 320f4af397c1..000000000000
--- a/Modules/AzTable/2.1.0/AzTable.psd1
+++ /dev/null
@@ -1,52 +0,0 @@
-@{
-
-# ID used to uniquely identify this module
-GUID = '0ed51f07-bcc5-429d-9322-0477168a0926'
-
-# Author of this module
-Author = 'Paulo Marques (MSFT)'
-
-# Company or vendor of this module
-CompanyName = 'Microsoft Corporation'
-
-# Copyright statement for this module
-Copyright = '© Microsoft Corporation. All rights reserved.'
-
-# Description of the functionality provided by this module
-Description = 'Sample functions to add/retrieve/update entities on Azure Storage Tables from PowerShell (This is the same as AzureRmStorageTable module but with a new module name). It requires latest PowerShell Az module installed. Instructions at https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-1.6.0. For documentation, please visit https://paulomarquesc.github.io/working-with-azure-storage-tables-from-powershell/.'
-
-# HelpInfo URI of this module
-HelpInfoUri = 'https://github.com/paulomarquesc/AzureRmStorageTable/tree/master/docs'
-
-# Version number of this module
-ModuleVersion = '2.1.0'
-
-# Minimum version of the Windows PowerShell engine required by this module
-PowerShellVersion = '4.0'
-
-# Minimum version of the common language runtime (CLR) required by this module
-CLRVersion = '2.0'
-
-# Script module or binary module file associated with this manifest
-#ModuleToProcess = ''
-
-# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
-NestedModules = @('AzureRmStorageTableCoreHelper.psm1')
-
-FunctionsToExport = @( 'Add-AzTableRow',
- 'Get-AzTableRow',
- 'Get-AzTableRowAll',
- 'Get-AzTableRowByPartitionKeyRowKey',
- 'Get-AzTableRowByPartitionKey',
- 'Get-AzTableRowByColumnName',
- 'Get-AzTableRowByCustomFilter',
- 'Update-AzTableRow',
- 'Remove-AzTableRow',
- 'Get-AzTableTable'
- )
-
-VariablesToExport = ''
-
-AliasesToExport = '*'
-
-}
diff --git a/Modules/AzTable/2.1.0/AzureRmStorageTableCoreHelper.psm1 b/Modules/AzTable/2.1.0/AzureRmStorageTableCoreHelper.psm1
deleted file mode 100644
index bb3206c783ee..000000000000
--- a/Modules/AzTable/2.1.0/AzureRmStorageTableCoreHelper.psm1
+++ /dev/null
@@ -1,834 +0,0 @@
-
-<#
-.SYNOPSIS
- AzureRmStorageTableCoreHelper.psm1 - PowerShell Module that contains all functions related to manipulating Azure Storage Table rows/entities.
-.DESCRIPTION
- AzureRmStorageTableCoreHelper.psm1 - PowerShell Module that contains all functions related to manipulating Azure Storage Table rows/entities.
-.NOTES
- This module depends on Az.Accounts, Az.Resources and Az.Storage PowerShell modules
-#>
-[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
-
-#Requires -modules Az.Storage
-
-# Deprecated Message
-$DeprecatedMessage = "IMPORTANT: This function is deprecated and will be removed in the next release, please use Get-AzTableRow instead."
-
-# Module Functions
-
-function TestAzTableEmptyKeys {
- param
- (
- [Parameter(Mandatory = $true)]
- $PartitionKey,
-
- [Parameter(Mandatory = $true)]
- $RowKey
- )
-
- $CosmosEmptyKeysErrorMessage = "Cosmos DB table API does not accept empty partition or row keys when using CloudTable.Execute operation, because of this we are disabling this capability in this module and it will not proceed."
-
- if ([string]::IsNullOrEmpty($PartitionKey) -or [string]::IsNullOrEmpty($RowKey)) {
- Throw $CosmosEmptyKeysErrorMessage
- }
-}
-
-function ExecuteQueryAsync {
- param
- (
- [Parameter(Mandatory = $true)]
- $Table,
- [Parameter(Mandatory = $true)]
- $TableQuery
- )
- # Internal function
- # Executes query in async mode
-
- if ($TableQuery -ne $null) {
- $token = $null
- $AllRows = @()
- do {
- $Results = $Table.ExecuteQuerySegmentedAsync($TableQuery, $token)
- $token = $Results.Result.ContinuationToken
- $AllRows += $Results.Result.Results
- # TakeCount controls the number of results returned per page, not
- # for the entire query. See e.g. the note in
- # https://docs.microsoft.com/azure/cosmos-db/table-storage-design-guide#retrieve-large-numbers-of-entities-from-a-query
- if (($null -ne $token) -and ($null -ne $TableQuery.TakeCount)) {
- # If the take count is larger than the number of rows in this
- # segment, there are more rows to return.
- if ($TableQuery.TakeCount -gt $Results.Result.Results.Count) {
- $TableQuery.TakeCount -= $Results.Result.Results.Count
- }
- else {
- # No more rows are available in the current page.
- break
- }
- }
- } while ($token)
-
- return $AllRows
- }
-}
-
-function GetPSObjectFromEntity($entityList) {
- # Internal function
- # Converts entities output from the ExecuteQuery method of table into an array of PowerShell Objects
-
- $returnObjects = @()
-
- if (-not [string]::IsNullOrEmpty($entityList)) {
- foreach ($entity in $entityList) {
- $entityNewObj = New-Object -TypeName psobject
- $entity.Properties.Keys | ForEach-Object { Add-Member -InputObject $entityNewObj -Name $_ -Value $entity.Properties[$_].PropertyAsObject -MemberType NoteProperty }
-
- # Adding table entity other attributes
- Add-Member -InputObject $entityNewObj -Name "PartitionKey" -Value $entity.PartitionKey -MemberType NoteProperty
- Add-Member -InputObject $entityNewObj -Name "RowKey" -Value $entity.RowKey -MemberType NoteProperty
- Add-Member -InputObject $entityNewObj -Name "TableTimestamp" -Value $entity.Timestamp -MemberType NoteProperty
- Add-Member -InputObject $entityNewObj -Name "Etag" -Value $entity.Etag -MemberType NoteProperty
-
- $returnObjects += $entityNewObj
- }
- }
-
- return $returnObjects
-
-}
-
-
-function Get-AzTableTable {
- <#
- .SYNOPSIS
- Gets a Table object to be used in all other cmdlets.
- .DESCRIPTION
- Gets a Table object to be used in all other cmdlets.
- .PARAMETER resourceGroup
- Resource Group where the Azure Storage Account is located
- .PARAMETER tableName
- Name of the table to retrieve
- .PARAMETER storageAccountName
- Storage Account name where the table lives
- .EXAMPLE
- # Getting storage table object
- $resourceGroup = "myResourceGroup"
- $storageAccount = "myStorageAccountName"
- $TableName = "table01"
- $Table = Get-AzTabletable -resourceGroup $resourceGroup -tableName $TableName -storageAccountName $storageAccount
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(ParameterSetName = "AzTableStorage", Mandatory = $true)]
- [string]$resourceGroup,
-
- [Parameter(Mandatory = $true)]
- [String]$TableName,
-
- [Parameter(ParameterSetName = "AzTableStorage", Mandatory = $true)]
- [String]$storageAccountName,
-
- [Parameter(ParameterSetName = "AzStorageEmulator", Mandatory = $true)]
- [switch]$UseStorageEmulator
- )
-
- # Validating name
- if ($TableName.Contains("_") -or $TableName.Contains("-")) {
- throw "Invalid table name: $TableName"
- }
-
- $nullTableErrorMessage = [string]::Empty
-
- if ($PSCmdlet.ParameterSetName -ne "AzStorageEmulator") {
- #$keys = Invoke-AzResourceAction -Action listKeys -ResourceType "Microsoft.Storage/storageAccounts" -ApiVersion "2017-10-01" -ResourceGroupName $resourceGroup -Name $storageAccountName -Force
- if ($keys -ne $null) {
- if ($PSCmdlet.ParameterSetName -eq "AzTableStorage" ) {
- $key = (($ENV:AzureWebJobsStorage).split(';') | ConvertFrom-StringData | ConvertTo-Json | ConvertFrom-Json).AccountKey
- $endpoint = "https://{0}.table.core.windows.net"
- $nullTableErrorMessage = "Table $TableName could not be retrieved from $storageAccountName on resource group $resourceGroupName"
- }
- else {
- # Future Cosmos implementation
- # $key = $keys.primaryMasterKey
- # $endpoint = "https://{0}.table.Cosmos.azure.com"
- # $nullTableErrorMessage = "Table $TableName could not be retrieved from $<<>> on resource group $resourceGroupName"
- }
- }
- else {
- throw "An error ocurred while obtaining keys from $storageAccountName."
- }
-
- $connString = [string]::Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};TableEndpoint=$endpoint", $storageAccountName, $key)
- [Microsoft.Azure.Cosmos.Table.CloudStorageAccount]$storageAccount = [Microsoft.Azure.Cosmos.Table.CloudStorageAccount]::Parse($connString)
- [Microsoft.Azure.Cosmos.Table.CloudTableClient]$TableClient = [Microsoft.Azure.Cosmos.Table.CloudTableClient]::new($storageAccount.TableEndpoint, $storageAccount.Credentials)
- [Microsoft.Azure.Cosmos.Table.CloudTable]$Table = [Microsoft.Azure.Cosmos.Table.CloudTable]$TableClient.GetTableReference($TableName)
-
- $Table.CreateIfNotExistsAsync() | Out-Null
- }
- else {
- # https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator
- $nullTableErrorMessage = "Table $TableName could not be retrieved from Azure Storage Emulator"
- $connString = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1"
- [Microsoft.Azure.Cosmos.Table.CloudStorageAccount]$storageAccount = [Microsoft.Azure.Cosmos.Table.CloudStorageAccount]::Parse($connString)
- [Microsoft.Azure.Cosmos.Table.CloudTableClient]$TableClient = [Microsoft.Azure.Cosmos.Table.CloudTableClient]::new($storageAccount.TableEndpoint, $storageAccount.Credentials)
- [Microsoft.Azure.Cosmos.Table.CloudTable]$Table = [Microsoft.Azure.Cosmos.Table.CloudTable]$TableClient.GetTableReference($TableName)
-
- $Table.CreateIfNotExistsAsync() | Out-Null
- }
-
- # Checking if there a table got returned
- if ($Table -eq $null) {
- throw $nullTableErrorMessage
- }
-
- return $Table
-}
-
-function Add-AzTableRow {
- <#
- .SYNOPSIS
- Adds a row/entity to a specified table
- .DESCRIPTION
- Adds a row/entity to a specified table
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable where the entity will be added
- .PARAMETER PartitionKey
- Identifies the table partition
- .PARAMETER RowKey
- Identifies a row within a partition
- .PARAMETER Property
- Hashtable with the columns that will be part of the entity. e.g. @{"firstName"="Paulo";"lastName"="Marques"}
- .PARAMETER UpdateExisting
- Signalizes that command should update existing row, if such found by PartitionKey and RowKey. If not found, new row is added.
- .EXAMPLE
- # Adding a row
- Add-AzTableRow -Table $Table -PartitionKey $PartitionKey -RowKey ([guid]::NewGuid().tostring()) -property @{"firstName"="Paulo";"lastName"="Costa";"role"="presenter"}
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- $Table,
-
- [Parameter(Mandatory = $true)]
- [AllowEmptyString()]
- [String]$PartitionKey,
-
- [Parameter(Mandatory = $true)]
- [AllowEmptyString()]
- [String]$RowKey,
-
- [Parameter(Mandatory = $false)]
- [hashtable]$property,
- [Switch]$UpdateExisting
- )
-
- # Creates the table entity with mandatory PartitionKey and RowKey arguments
- $entity = New-Object -TypeName "Microsoft.Azure.Cosmos.Table.DynamicTableEntity" -ArgumentList $PartitionKey, $RowKey
-
- # Adding the additional columns to the table entity
- foreach ($prop in $property.Keys) {
- if ($prop -ne "TableTimestamp") {
- $entity.Properties.Add($prop, $property.Item($prop))
- }
- }
-
- if ($UpdateExisting) {
- return ($Table.Execute([Microsoft.Azure.Cosmos.Table.TableOperation]::InsertOrReplace($entity)))
- }
- else {
- return ($Table.Execute([Microsoft.Azure.Cosmos.Table.TableOperation]::Insert($entity)))
- }
-}
-
-function Get-AzTableRowAll {
- <#
- .SYNOPSIS
- Returns all rows/entities from a storage table - no Filtering
- .DESCRIPTION
- Returns all rows/entities from a storage table - no Filtering
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable to retrieve entities
- .EXAMPLE
- # Getting all rows
- Get-AzTableRowAll -Table $Table
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- $Table
- )
-
- Write-Verbose $DeprecatedMessage -Verbose
-
- # No Filtering
-
- $Result = Get-AzTableRow -Table $Table
-
- if (-not [string]::IsNullOrEmpty($Result)) {
- return $Result
- }
-
-}
-
-function Get-AzTableRowByPartitionKey {
- <#
- .SYNOPSIS
- Returns one or more rows/entities based on Partition Key
- .DESCRIPTION
- Returns one or more rows/entities based on Partition Key
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable to retrieve entities
- .PARAMETER PartitionKey
- Identifies the table partition
- .PARAMETER Top
- Return only the first n rows from the query
- .EXAMPLE
- # Getting rows by partition Key
- Get-AzTableRowByPartitionKey -Table $Table -PartitionKey "mypartitionkey"
- .EXAMPLE
- # Getting rows by partition key with a maximum number returned
- Get-AzTableRowByPartitionKey -Table $Table -PartitionKey "mypartitionkey" -Top 10
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- $Table,
-
- [Parameter(Mandatory = $true)]
- [AllowEmptyString()]
- [string]$PartitionKey,
-
- [Parameter(Mandatory = $false)]
- [Nullable[Int32]]$Top = $null
- )
-
- Write-Verbose $DeprecatedMessage -Verbose
-
- # Filtering by Partition Key
- $Result = Get-AzTableRow -Table $Table -PartitionKey $PartitionKey -Top $Top
-
- if (-not [string]::IsNullOrEmpty($Result)) {
- return $Result
- }
-
-}
-function Get-AzTableRowByPartitionKeyRowKey {
- <#
- .SYNOPSIS
- Returns one entity based on Partition Key and RowKey
- .DESCRIPTION
- Returns one entity based on Partition Key and RowKey
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable to retrieve entities
- .PARAMETER PartitionKey
- Identifies the table partition
- .PARAMETER RowKey
- Identifies the row key in the partition
- .PARAMETER Top
- Return only the first n rows from the query
- .EXAMPLE
- # Getting rows by Partition Key and Row Key
- Get-AzStorageTableRowByPartitionKeyRowKey -Table $Table -PartitionKey "partition1" -RowKey "id12345"
- .EXAMPLE
- # Getting rows by Partition Key and Row Key, with a maximum number returned
- Get-AzStorageTableRowByPartitionKeyRowKey -Table $Table -PartitionKey "partition1" -RowKey "id12345" -Top 10
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- $Table,
-
- [Parameter(Mandatory = $true)]
- [AllowEmptyString()]
- [string]$PartitionKey,
-
- [Parameter(Mandatory = $true)]
- [AllowEmptyString()]
- [string]$RowKey,
-
- [Parameter(Mandatory = $false)]
- [Nullable[Int32]]$Top = $null
- )
-
- # Filtering by Partition Key and Row Key
-
- Write-Verbose $DeprecatedMessage -Verbose
-
- $Result = Get-AzTableRow -Table $Table -PartitionKey $PartitionKey -RowKey $RowKey -Top $Top
-
- if (-not [string]::IsNullOrEmpty($Result)) {
- return $Result
- }
-}
-
-function Get-AzTableRowByColumnName {
- <#
- .SYNOPSIS
- Returns one or more rows/entities based on a specified column and its value
- .DESCRIPTION
- Returns one or more rows/entities based on a specified column and its value
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable to retrieve entities
- .PARAMETER ColumnName
- Column name to compare the value to
- .PARAMETER Value
- Value that will be looked for in the defined column
- .PARAMETER GuidValue
- Value that will be looked for in the defined column as Guid
- .PARAMETER Operator
- Supported comparison Operator. Valid values are "Equal","GreaterThan","GreaterThanOrEqual","LessThan" ,"LessThanOrEqual" ,"NotEqual"
- .PARAMETER Top
- Return only the first n rows from the query
- .EXAMPLE
- # Getting row by firstname
- Get-AzTableRowByColumnName -Table $Table -ColumnName "firstName" -value "Paulo" -Operator Equal
- .EXAMPLE
- # Getting row by firstname with a maximum number of rows returned
- Get-AzTableRowByColumnName -Table $Table -ColumnName "firstName" -value "Paulo" -Operator Equal -Top 10
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- $Table,
-
- [Parameter(Mandatory = $true)]
- [string]$ColumnName,
-
- [Parameter(ParameterSetName = "byString", Mandatory = $true)]
- [AllowEmptyString()]
- [string]$Value,
-
- [Parameter(ParameterSetName = "byGuid", Mandatory = $true)]
- [guid]$GuidValue,
-
- [Parameter(Mandatory = $true)]
- [validateSet("Equal", "GreaterThan", "GreaterThanOrEqual", "LessThan" , "LessThanOrEqual" , "NotEqual")]
- [string]$Operator,
-
- [Parameter(Mandatory = $false)]
- [Nullable[Int32]]$Top = $null
- )
-
- Write-Verbose $DeprecatedMessage -Verbose
-
- # Filtering by Columnn Name
-
- if ($PSCmdlet.ParameterSetName -eq "byString") {
- Get-AzTableRow -Table $Table -ColumnName $ColumnName -Value $Value -Operator $Operator -Top $Top
- }
- else {
- Get-AzTableRow -Table $Table -ColumnName $ColumnName -GuidValue $GuidValue -Operator $Operator -Top $Top
- }
-
- if (-not [string]::IsNullOrEmpty($Result)) {
- return $Result
- }
-}
-
-function Get-AzTableRowByCustomFilter {
- <#
- .SYNOPSIS
- Returns one or more rows/entities based on custom Filter.
- .DESCRIPTION
- Returns one or more rows/entities based on custom Filter. This custom Filter can be
- built using the Microsoft.Azure.Cosmos.Table.TableQuery class or direct text.
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable to retrieve entities
- .PARAMETER CustomFilter
- Custom Filter string.
- .PARAMETER Top
- Return only the first n rows from the query
- .EXAMPLE
- # Getting row by firstname by using the class Microsoft.Azure.Cosmos.Table.TableQuery
- $MyFilter = "(firstName eq 'User1')"
- Get-AzTableRowByCustomFilter -Table $Table -CustomFilter $MyFilter
- .EXAMPLE
- # Getting row by firstname by using text Filter directly (oData Filter format)
- Get-AzTableRowByCustomFilter -Table $Table -CustomFilter "(firstName eq 'User1') and (lastName eq 'LastName1')"
- .EXAMPLE
- # Getting row by firstname by using text Filter directly with a maximum number of rows returned
- Get-AzTableRowByCustomFilter -Table $Table -CustomFilter "(firstName eq 'User1') and (lastName eq 'LastName1')" -Top 10
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- $Table,
-
- [Parameter(Mandatory = $true)]
- [string]$CustomFilter,
-
- [Parameter(Mandatory = $false)]
- [Nullable[Int32]]$Top = $null
- )
-
- Write-Verbose $DeprecatedMessage -Verbose
-
- # Custom Filter
-
- $Result = Get-AzTableRow -Table $Table -CustomFilter $CustomFilter -Top $Top
-
- if (-not [string]::IsNullOrEmpty($Result)) {
- return $Result
- }
-}
-
-function Get-AzTableRow {
- <#
- .SYNOPSIS
- Used to return entities from a table with several options, this replaces all other Get-AzTable cmdlets.
- .DESCRIPTION
- Used to return entities from a table with several options, this replaces all other Get-AzTable cmdlets.
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable to retrieve entities (common to all parameter sets)
- .PARAMETER PartitionKey
- Identifies the table partition (byPartitionKey and byPartRowKeys parameter sets)
- .PARAMETER RowKey
- Identifies the row key in the partition (byPartRowKeys parameter set)
- .PARAMETER SelectColumn
- Names of the properties to return for each entity
- .PARAMETER ColumnName
- Column name to compare the value to (byColummnString and byColummnGuid parameter sets)
- .PARAMETER Value
- Value that will be looked for in the defined column (byColummnString parameter set)
- .PARAMETER GuidValue
- Value that will be looked for in the defined column as Guid (byColummnGuid parameter set)
- .PARAMETER Operator
- Supported comparison Operator. Valid values are "Equal","GreaterThan","GreaterThanOrEqual","LessThan" ,"LessThanOrEqual" ,"NotEqual" (byColummnString and byColummnGuid parameter sets)
- .PARAMETER CustomFilter
- Custom Filter string (byCustomFilter parameter set)
- .PARAMETER Top
- Return only the first n rows from the query (all parameter sets)
- .EXAMPLE
- # Getting all rows
- Get-AzTableRow -Table $Table
- .EXAMPLE
- # Getting specific properties for all rows
- $columns = ('osVersion', 'computerName')
- Get-AzTableRow -Table $Table -SelectColumn $columns
- .EXAMPLE
- # Getting rows by partition key
- Get-AzTableRow -Table $table -partitionKey NewYorkSite
- .EXAMPLE
- # Getting rows by partition and row key
- Get-AzTableRow -Table $table -partitionKey NewYorkSite -rowKey "afc04476-bda0-47ea-a9e9-7c739c633815"
- .EXAMPLE
- # Getting rows by Columnm Name using Guid columns in table
- Get-AzTableRow -Table $Table -ColumnName "id" -guidvalue "5fda3053-4444-4d23-b8c2-b26e946338b6" -operator Equal
- .EXAMPLE
- # Getting rows by Columnm Name using string columns in table
- Get-AzTableRow -Table $Table -ColumnName "osVersion" -value "Windows NT 4" -operator Equal
- .EXAMPLE
- # Getting rows using Custom Filter
- Get-AzTableRow -Table $Table -CustomFilter "(osVersion eq 'Windows NT 4') and (computerName eq 'COMP07')"
- .EXAMPLE
- # Querying with a maximum number of rows returned
- Get-AzTableRow -Table $Table -partitionKey NewYorkSite -Top 10
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true, ParameterSetName = "GetAll")]
- [Parameter(ParameterSetName = "byPartitionKey")]
- [Parameter(ParameterSetName = "byPartRowKeys")]
- [Parameter(ParameterSetName = "byColummnString")]
- [Parameter(ParameterSetName = "byColummnGuid")]
- [Parameter(ParameterSetName = "byCustomFilter")]
- $Table,
-
- [Parameter(ParameterSetName = "GetAll")]
- [Parameter(ParameterSetName = "byPartitionKey")]
- [Parameter(ParameterSetName = "byPartRowKeys")]
- [Parameter(ParameterSetName = "byColummnString")]
- [Parameter(ParameterSetName = "byColummnGuid")]
- [Parameter(ParameterSetName = "byCustomFilter")]
- [System.Collections.Generic.List[string]]$SelectColumn,
-
- [Parameter(Mandatory = $true, ParameterSetName = "byPartitionKey")]
- [Parameter(ParameterSetName = "byPartRowKeys")]
- [AllowEmptyString()]
- [string]$PartitionKey,
-
- [Parameter(Mandatory = $true, ParameterSetName = "byPartRowKeys")]
- [AllowEmptyString()]
- [string]$RowKey,
-
- [Parameter(Mandatory = $true, ParameterSetName = "byColummnString")]
- [Parameter(ParameterSetName = "byColummnGuid")]
- [string]$ColumnName,
-
- [Parameter(Mandatory = $true, ParameterSetName = "byColummnString")]
- [AllowEmptyString()]
- [string]$Value,
-
- [Parameter(ParameterSetName = "byColummnGuid", Mandatory = $true)]
- [guid]$GuidValue,
-
- [Parameter(Mandatory = $true, ParameterSetName = "byColummnString")]
- [Parameter(ParameterSetName = "byColummnGuid")]
- [validateSet("Equal", "GreaterThan", "GreaterThanOrEqual", "LessThan" , "LessThanOrEqual" , "NotEqual")]
- [string]$Operator,
-
- [Parameter(Mandatory = $true, ParameterSetName = "byCustomFilter")]
- [string]$CustomFilter,
-
- [Parameter(Mandatory = $false)]
- [Nullable[Int32]]$Top = $null
- )
-
- $TableQuery = New-Object -TypeName "Microsoft.Azure.Cosmos.Table.TableQuery"
-
- # Building filters if any
- if ($PSCmdlet.ParameterSetName -eq "byPartitionKey") {
- [string]$Filter = `
- [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition("PartitionKey", `
- [Microsoft.Azure.Cosmos.Table.QueryComparisons]::Equal, $PartitionKey)
- }
- elseif ($PSCmdlet.ParameterSetName -eq "byPartRowKeys") {
- [string]$FilterA = `
- [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition("PartitionKey", `
- [Microsoft.Azure.Cosmos.Table.QueryComparisons]::Equal, $PartitionKey)
-
- [string]$FilterB = `
- [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition("RowKey", `
- [Microsoft.Azure.Cosmos.Table.QueryComparisons]::Equal, $RowKey)
-
- [string]$Filter = [Microsoft.Azure.Cosmos.Table.TableQuery]::CombineFilters($FilterA, "and", $FilterB)
- }
- elseif ($PSCmdlet.ParameterSetName -eq "byColummnString") {
- [string]$Filter = `
- [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition($ColumnName, [Microsoft.Azure.Cosmos.Table.QueryComparisons]::$Operator, $Value)
- }
- elseif ($PSCmdlet.ParameterSetName -eq "byColummnGuid") {
- [string]$Filter = `
- [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterConditionForGuid($ColumnName, [Microsoft.Azure.Cosmos.Table.QueryComparisons]::$Operator, $GuidValue)
- }
- elseif ($PSCmdlet.ParameterSetName -eq "byCustomFilter") {
- [string]$Filter = $CustomFilter
- }
- else {
- [string]$filter = $null
- }
-
- # Adding filter if not null
- if (-not [string]::IsNullOrEmpty($Filter)) {
- $TableQuery.FilterString = $Filter
- }
-
- # Selecting columns if specified
- if ($null -ne $SelectColumn) {
- $TableQuery.SelectColumns = $SelectColumn
- }
-
- # Set number of rows to return.
- if ($null -ne $Top) {
- $TableQuery.TakeCount = $Top
- }
-
- # Getting results
- if (($TableQuery.FilterString -ne $null) -or ($PSCmdlet.ParameterSetName -eq "GetAll")) {
- $Result = ExecuteQueryAsync -Table $Table -TableQuery $TableQuery
-
- # if (-not [string]::IsNullOrEmpty($Result.Result.Results))
- # {
- # return (GetPSObjectFromEntity($Result.Result.Results))
- # }
-
- if (-not [string]::IsNullOrEmpty($Result)) {
- return (GetPSObjectFromEntity($Result))
- }
- }
-}
-function Update-AzTableRow {
- <#
- .SYNOPSIS
- Updates a table entity
- .DESCRIPTION
- Updates a table entity. To work with this cmdlet, you need first retrieve an entity with one of the Get-AzTableRow cmdlets available
- and store in an object, change the necessary properties and then perform the update passing this modified entity back, through Pipeline or as argument.
- Notice that this cmdlet accepts only one entity per execution.
- This cmdlet cannot update Partition Key and/or RowKey because it uses those two values to locate the entity to update it, if this operation is required
- please delete the old entity and add the new one with the updated values instead.
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable where the entity exists
- .PARAMETER Entity
- The entity/row with new values to perform the update.
- .EXAMPLE
- # Updating an entity
-
- [string]$Filter = [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition("firstName",[Microsoft.Azure.Cosmos.Table.QueryComparisons]::Equal,"User1")
- $person = Get-AzTableRowByCustomFilter -Table $Table -CustomFilter $Filter
- $person.lastName = "New Last Name"
- $person | Update-AzTableRow -Table $Table
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- $Table,
-
- [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
- $entity
- )
-
- # Only one entity at a time can be updated
- $updatedEntityList = @()
- $updatedEntityList += $entity
-
- if ($updatedEntityList.Count -gt 1) {
- throw "Update operation can happen on only one entity at a time, not in a list/array of entities."
- }
-
- $updatedEntity = New-Object -TypeName "Microsoft.Azure.Cosmos.Table.DynamicTableEntity" -ArgumentList $entity.PartitionKey, $entity.RowKey
-
- # Iterating over PS Object properties to add to the updated entity
- foreach ($prop in $entity.psobject.Properties) {
- if (($prop.name -ne "PartitionKey") -and ($prop.name -ne "RowKey") -and ($prop.name -ne "Timestamp") -and ($prop.name -ne "Etag") -and ($prop.name -ne "TableTimestamp")) {
- $updatedEntity.Properties.Add($prop.name, $prop.Value)
- }
- }
-
- $updatedEntity.ETag = $entity.Etag
- $updatedEntity.Timestamp = $entity.TableTimestamp
-
- # Updating the dynamic table entity to the table
- # return ($Table.ExecuteAsync([Microsoft.Azure.Cosmos.Table.TableOperation]::InsertOrMerge($updatedEntity)))
- return ($Table.Execute([Microsoft.Azure.Cosmos.Table.TableOperation]::InsertOrMerge($updatedEntity)))
-}
-
-function Remove-AzTableRow {
- <#
- .SYNOPSIS
- Remove-AzTableRow - Removes a specified table row
- .DESCRIPTION
- Remove-AzTableRow - Removes a specified table row. It accepts multiple deletions through the Pipeline when passing entities returned from the Get-AzTableRow
- available cmdlets. It also can delete a row/entity using Partition and Row Key properties directly.
- .PARAMETER Table
- Table object of type Microsoft.Azure.Cosmos.Table.CloudTable where the entity exists
- .PARAMETER Entity (ParameterSetName=byEntityPSObjectObject)
- The entity/row with new values to perform the deletion.
- .PARAMETER PartitionKey (ParameterSetName=byPartitionandRowKeys)
- Partition key where the entity belongs to.
- .PARAMETER RowKey (ParameterSetName=byPartitionandRowKeys)
- Row key that uniquely identifies the entity within the partition.
- .EXAMPLE
- # Deleting an entry by entity PS Object
- [string]$Filter1 = [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition("firstName",[Microsoft.Azure.Cosmos.Table.QueryComparisons]::Equal,"Paulo")
- [string]$Filter2 = [Microsoft.Azure.Cosmos.Table.TableQuery]::GenerateFilterCondition("lastName",[Microsoft.Azure.Cosmos.Table.QueryComparisons]::Equal,"Marques")
- [string]$finalFilter = [Microsoft.Azure.Cosmos.Table.TableQuery]::CombineFilters($Filter1,"and",$Filter2)
- $personToDelete = Get-AzTableRowByCustomFilter -Table $Table -CustomFilter $finalFilter
- $personToDelete | Remove-AzTableRow -Table $Table
- .EXAMPLE
- # Deleting an entry by using PartitionKey and row key directly
- Remove-AzTableRow -Table $Table -PartitionKey "TableEntityDemoFullList" -RowKey "399b58af-4f26-48b4-9b40-e28a8b03e867"
- .EXAMPLE
- # Deleting everything
- Get-AzTableRowAll -Table $Table | Remove-AzTableRow -Table $Table
- #>
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory = $true)]
- $Table,
-
- [Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = "byEntityPSObjectObject")]
- $entity,
-
- [Parameter(Mandatory = $true, ParameterSetName = "byPartitionandRowKeys")]
- [AllowEmptyString()]
- [string]$PartitionKey,
-
- [Parameter(Mandatory = $true, ParameterSetName = "byPartitionandRowKeys")]
- [AllowEmptyString()]
- [string]$RowKey
- )
-
- begin {
- $updatedEntityList = @()
- $updatedEntityList += $entity
-
- if ($updatedEntityList.Count -gt 1) {
- throw "Delete operation cannot happen on an array of entities, altough you can pipe multiple items."
- }
-
- $Results = @()
- }
-
- process {
- if ($PSCmdlet.ParameterSetName -eq "byEntityPSObjectObject") {
- $PartitionKey = $entity.PartitionKey
- $RowKey = $entity.RowKey
- }
-
- $TableQuery = New-Object -TypeName "Microsoft.Azure.Cosmos.Table.TableQuery"
- $Filter = "(PartitionKey eq '$($PartitionKey)') and (RowKey eq '$($RowKey)')"
- $TableQuery.FilterString = $Filter
- $itemToDelete = ExecuteQueryAsync -Table $Table -TableQuery $TableQuery
-
- if ($itemToDelete -ne $null) {
- # Converting DynamicTableEntity to TableEntity for deletion
- $entityToDelete = New-Object -TypeName "Microsoft.Azure.Cosmos.Table.TableEntity"
- $entityToDelete.ETag = $itemToDelete.Etag
- $entityToDelete.PartitionKey = $itemToDelete.PartitionKey
- $entityToDelete.RowKey = $itemToDelete.RowKey
-
- $Results += $Table.Execute([Microsoft.Azure.Cosmos.Table.TableOperation]::Delete($entityToDelete))
- }
-
- }
-
- end {
- return , $Results
- }
-}
-
-# Aliases
-
-If (-not (Get-Alias -Name Add-StorageTableRow -ErrorAction SilentlyContinue)) {
- New-Alias -Name Add-StorageTableRow -Value Add-AzTableRow
-}
-
-If (-not (Get-Alias -Name Add-AzureStorageTableRow -ErrorAction SilentlyContinue)) {
- New-Alias -Name Add-AzureStorageTableRow -Value Add-AzTableRow
-}
-
-If (-not (Get-Alias -Name Get-AzureStorageTableTable -ErrorAction SilentlyContinue)) {
- New-Alias -Name Get-AzureStorageTableTable -Value Get-AzTableTable
-}
-
-If (-not (Get-Alias -Name Get-AzureStorageTableRowAll -ErrorAction SilentlyContinue)) {
- New-Alias -Name Get-AzureStorageTableRowAll -Value Get-AzTableRowAll
-}
-
-If (-not (Get-Alias -Name Get-AzureStorageTableRowByPartitionKey -ErrorAction SilentlyContinue)) {
- New-Alias -Name Get-AzureStorageTableRowByPartitionKey -Value Get-AzTableRowByPartitionKey
-}
-
-If (-not (Get-Alias -Name Get-AzureStorageTableRowByPartitionKeyRowKey -ErrorAction SilentlyContinue)) {
- New-Alias -Name Get-AzureStorageTableRowByPartitionKeyRowKey -Value Get-AzTableRowByPartitionKeyRowKey
-}
-
-If (-not (Get-Alias -Name Get-AzureStorageTableRowByColumnName -ErrorAction SilentlyContinue)) {
- New-Alias -Name Get-AzureStorageTableRowByColumnName -Value Get-AzTableRowByColumnName
-}
-
-If (-not (Get-Alias -Name Get-AzureStorageTableRowByCustomFilter -ErrorAction SilentlyContinue)) {
- New-Alias -Name Get-AzureStorageTableRowByCustomFilter -Value Get-AzTableRowByCustomFilter
-}
-
-If (-not (Get-Alias -Name Get-AzureStorageTableRow -ErrorAction SilentlyContinue)) {
- New-Alias -Name Get-AzureStorageTableRow -Value Get-AzTableRow
-}
-
-If (-not (Get-Alias -Name Update-AzureStorageTableRow -ErrorAction SilentlyContinue)) {
- New-Alias -Name Update-AzureStorageTableRow -Value Update-AzTableRow
-}
-
-If (-not (Get-Alias -Name Remove-AzureStorageTableRow -ErrorAction SilentlyContinue)) {
- New-Alias -Name Remove-AzureStorageTableRow -Value Remove-AzTableRow
-}
diff --git a/Modules/AzTable/2.1.0/LICENSE b/Modules/AzTable/2.1.0/LICENSE
deleted file mode 100644
index 01156177e004..000000000000
--- a/Modules/AzTable/2.1.0/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2017 Paulo Marques
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/Modules/AzTable/2.1.0/PSGetModuleInfo.xml b/Modules/AzTable/2.1.0/PSGetModuleInfo.xml
deleted file mode 100644
index a2703746cb14..000000000000
Binary files a/Modules/AzTable/2.1.0/PSGetModuleInfo.xml and /dev/null differ
diff --git a/PublicScripts/run.ps1 b/PublicScripts/run.ps1
index b95b530bafb8..750a5f1f3744 100644
--- a/PublicScripts/run.ps1
+++ b/PublicScripts/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
# Write to the Azure Functions log stream.
Write-Host 'PowerShell HTTP trigger function processed a request.'
@@ -12,7 +12,8 @@ Write-Host 'PowerShell HTTP trigger function processed a request.'
$Table = Get-CippTable -TableName 'MaintenanceScripts'
if (![string]::IsNullOrEmpty($Request.Query.Guid)) {
- $ScriptRow = Get-AzTableRow -Table $Table -PartitionKey 'Maintenance' -RowKey $Request.Query.Guid
+ $Filter = "PartitionKey eq 'Maintenance' and RowKey eq '{0}'" -f $Request.Query.Guid
+ $ScriptRow = Get-AzDataTableEntity @Table -Filter $Filter
if ($ScriptRow) {
if ($ScriptRow.TableTimestamp -lt (Get-Date).AddMinutes(-5)) {
$Body = 'Write-Host "Link expired"'
@@ -20,7 +21,7 @@ if (![string]::IsNullOrEmpty($Request.Query.Guid)) {
else {
$Body = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($ScriptRow.ScriptContent))
}
- $ScriptRow | Remove-AzTableRow -Table $Table
+ Remove-AzDataTableEntity @Table -Entity $ScriptRow
}
else {
$Body = 'Write-Host "Invalid Script ID"'
diff --git a/RemoveAPDevice/run.ps1 b/RemoveAPDevice/run.ps1
index a6a32601b8da..c99035f34378 100644
--- a/RemoveAPDevice/run.ps1
+++ b/RemoveAPDevice/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
@@ -19,11 +19,11 @@ try {
else {
$GraphRequest = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotDeviceIdentities/$Deviceid" -tenantid $TenantFilter -type DELETE
}
- Log-Request -user $request.headers.'x-ms-client-principal' -tenant $TenantFilter -API $APINAME -message "Deleted autopilot device $Deviceid" -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -tenant $TenantFilter -API $APINAME -message "Deleted autopilot device $Deviceid" -Sev "Info"
$body = [pscustomobject]@{"Results" = "Succesfully deleted the autopilot device" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -tenant $TenantFilter -API $APINAME -message "Autopilot Delete API failed for $deviceid. The error is: $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -tenant $TenantFilter -API $APINAME -message "Autopilot Delete API failed for $deviceid. The error is: $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to delete device: $($_.Exception.Message)" }
}
#force a sync, this can give "too many requests" if deleleting a bunch of devices though.
diff --git a/RemoveApp/run.ps1 b/RemoveApp/run.ps1
index cabd77dddb41..86fd9a55e3ab 100644
--- a/RemoveApp/run.ps1
+++ b/RemoveApp/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
@@ -13,11 +13,11 @@ if (!$policyId) { exit }
try {
#$unAssignRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/deviceManagement/configurationPolicies('$($policyId)')/assign" -type POST -Body '{"assignments":[]}' -tenant $TenantFilter
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$($policyId)" -type DELETE -tenant $TenantFilter
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted $policyId" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted $policyId" -Sev "Info" -tenant $TenantFilter
$body = [pscustomobject]@{"Results" = "Succesfully deleted the application" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete app $policyId. $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete app $policyId. $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
$body = [pscustomobject]@{"Results" = "Could not delete this application: $($_.Exception.Message)" }
}
diff --git a/RemoveCAPolicy/run.ps1 b/RemoveCAPolicy/run.ps1
index 77f46cb17646..b187d07c6889 100644
--- a/RemoveCAPolicy/run.ps1
+++ b/RemoveCAPolicy/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
@@ -12,12 +12,12 @@ $policyId = $Request.Query.GUID
if (!$policyId) { exit }
try {
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies/$($policyId)" -type DELETE -tenant $TenantFilter
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted CA Policy $policyId" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted CA Policy $policyId" -Sev "Info" -tenant $TenantFilter
$body = [pscustomobject]@{"Results" = "Succesfully deleted the policy" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete CA policy $policyId. $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete CA policy $policyId. $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
$body = [pscustomobject]@{"Results" = "Could not delete policy: $($_.Exception.Message)" }
}
diff --git a/RemoveCATemplate/run.ps1 b/RemoveCATemplate/run.ps1
index f7a47300cbc9..1e9281cda704 100644
--- a/RemoveCATemplate/run.ps1
+++ b/RemoveCATemplate/run.ps1
@@ -4,16 +4,16 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$ID = $request.query.id
try {
Remove-Item "Config\$($ID).CATemplate.json" -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed Conditional Access Template with ID $ID." -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed Conditional Access Template with ID $ID." -Sev "Info"
$body = [pscustomobject]@{"Results" = "Successfully removed Conditional Access Template" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove Conditional Access template $ID. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove Conditional Access template $ID. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to remove template" }
}
diff --git a/RemoveIntuneTemplate/run.ps1 b/RemoveIntuneTemplate/run.ps1
index 052d6d411aa1..4086a63e94c7 100644
--- a/RemoveIntuneTemplate/run.ps1
+++ b/RemoveIntuneTemplate/run.ps1
@@ -4,16 +4,16 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$ID = $request.query.id
try {
Remove-Item "Config\$($ID).IntuneTemplate.json" -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed Intune Template with ID $ID." -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed Intune Template with ID $ID." -Sev "Info"
$body = [pscustomobject]@{"Results" = "Successfully removed Intune Template" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove intune template $ID. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove intune template $ID. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to remove template" }
}
diff --git a/RemovePolicy/run.ps1 b/RemovePolicy/run.ps1
index d6948937d826..2bcbbf72d61d 100644
--- a/RemovePolicy/run.ps1
+++ b/RemovePolicy/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
@@ -14,12 +14,12 @@ try {
#$unAssignRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/deviceManagement/configurationPolicies('$($policyId)')/assign" -type POST -Body '{"assignments":[]}' -tenant $TenantFilter
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/deviceManagement/$($Request.Query.URLName)('$($policyId)')" -type DELETE -tenant $TenantFilter
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted $policyId" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted $policyId" -Sev "Info" -tenant $TenantFilter
$body = [pscustomobject]@{"Results" = "Succesfully deleted the policy" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete policy $policyId. $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete policy $policyId. $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
$body = [pscustomobject]@{"Results" = "Could not delete policy: $($_.Exception.Message)" }
}
diff --git a/RemoveQueuedAlert/run.ps1 b/RemoveQueuedAlert/run.ps1
index b158f0228700..a023df1908c5 100644
--- a/RemoveQueuedAlert/run.ps1
+++ b/RemoveQueuedAlert/run.ps1
@@ -4,17 +4,19 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
-$Table = Get-CIPPTable -TableName "SchedulerConfig"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
+$Table = Get-CIPPTable -TableName 'SchedulerConfig'
$ID = $request.query.id
try {
- Remove-AzTableRow -Table $Table -RowKey $ID -PartitionKey "Alert"
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed application queue for $ID." -Sev "Info"
- $body = [pscustomobject]@{"Results" = "Successfully removed from queue." }
+ $Filter = "RowKey eq '{0}' and PartitionKey eq 'Alert'"
+ $Alert = Get-AzDataTableEntity @Table -Filter $Filter
+ Remove-AzDataTableEntity @Table -Entity $Alert
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed application queue for $ID." -Sev 'Info'
+ $body = [pscustomobject]@{'Results' = 'Successfully removed from queue.' }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove from queue $ID. $($_.Exception.Message)" -Sev "Error"
- $body = [pscustomobject]@{"Results" = "Failed to remove alert from queue $($_.Exception.Message)" }
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove from queue $ID. $($_.Exception.Message)" -Sev 'Error'
+ $body = [pscustomobject]@{'Results' = "Failed to remove alert from queue $($_.Exception.Message)" }
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
diff --git a/RemoveQueuedApp/run.ps1 b/RemoveQueuedApp/run.ps1
index b550359f72ca..21e6a7333af1 100644
--- a/RemoveQueuedApp/run.ps1
+++ b/RemoveQueuedApp/run.ps1
@@ -4,17 +4,17 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$user = $request.headers.'x-ms-client-principal'
$ID = $request.query.id
try {
Remove-Item "ChocoApps.cache\$($ID)" -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed application queue for $ID." -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed application queue for $ID." -Sev "Info"
$body = [pscustomobject]@{"Results" = "Successfully removed from queue." }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove application queue for $ID. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove application queue for $ID. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to remove standard)" }
}
diff --git a/RemoveStandard/run.ps1 b/RemoveStandard/run.ps1
index 15905a22c88c..e3141b53ad63 100644
--- a/RemoveStandard/run.ps1
+++ b/RemoveStandard/run.ps1
@@ -4,19 +4,19 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$user = $request.headers.'x-ms-client-principal'
$ID = $request.query.id
try {
Remove-Item "Cache_Standards\$($ID).Standards.json" -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed standards for $ID." -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed standards for $ID." -Sev "Info"
$body = [pscustomobject]@{"Results" = "Successfully removed standards deployment" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove standard for $ID. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove standard for $ID. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to remove standard)" }
}
diff --git a/RemoveTransportRule/run.ps1 b/RemoveTransportRule/run.ps1
index 261bbc733006..bdba1680f357 100644
--- a/RemoveTransportRule/run.ps1
+++ b/RemoveTransportRule/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Tenantfilter = $request.Query.tenantfilter
@@ -16,7 +16,7 @@ try {
$cmdlet = "Remove-TransportRule"
$GraphRequest = New-ExoRequest -tenantid $Tenantfilter -cmdlet $cmdlet -cmdParams $params
$Result = "Deleted $($Request.query.guid)"
- Log-request -API "TransportRules" -tenant $tenantfilter -message "Deleted transport rule $($Request.query.guid)" -sev Debug
+ Write-LogMessage -API "TransportRules" -tenant $tenantfilter -message "Deleted transport rule $($Request.query.guid)" -sev Debug
}
catch {
$ErrorMessage = Get-NormalizedError -Message $_.Exception
diff --git a/RemoveTransportRuleTemplate/run.ps1 b/RemoveTransportRuleTemplate/run.ps1
index 57eeb7ac1d29..3cf42e650914 100644
--- a/RemoveTransportRuleTemplate/run.ps1
+++ b/RemoveTransportRuleTemplate/run.ps1
@@ -4,16 +4,16 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$ID = $request.query.id
try {
Remove-Item "Config\$($ID).TransportRuleTemplate.json" -Force
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed Transport Rule Template with ID $ID." -Sev "Info"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Removed Transport Rule Template with ID $ID." -Sev "Info"
$body = [pscustomobject]@{"Results" = "Successfully removed Transport Rule Template" }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove Transport Rule template $ID. $($_.Exception.Message)" -Sev "Error"
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Failed to remove Transport Rule template $ID. $($_.Exception.Message)" -Sev "Error"
$body = [pscustomobject]@{"Results" = "Failed to remove template" }
}
diff --git a/RemoveUser/run.ps1 b/RemoveUser/run.ps1
index 2a0c3f32071a..5539c46b1369 100644
--- a/RemoveUser/run.ps1
+++ b/RemoveUser/run.ps1
@@ -4,7 +4,7 @@ using namespace System.Net
param($Request, $TriggerMetadata)
$APIName = $TriggerMetadata.FunctionName
-Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
+Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
# Interact with query parameters or the body of the request.
$TenantFilter = $Request.Query.TenantFilter
@@ -12,12 +12,12 @@ $userid = $Request.Query.ID
if (!$userid) { exit }
try {
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($userid)" -type DELETE -tenant $TenantFilter
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted $userid" -Sev "Info" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Deleted $userid" -Sev "Info" -tenant $TenantFilter
$body = [pscustomobject]@{"Results" = "Succesfully deleted the user." }
}
catch {
- Log-Request -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete user $userid. $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
+ Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Could not delete user $userid. $($_.Exception.Message)" -Sev "Error" -tenant $TenantFilter
$body = [pscustomobject]@{"Results" = "Could not delete user: $($_.Exception.Message)" }
}
diff --git a/Scheduler_Alert/run.ps1 b/Scheduler_Alert/run.ps1
index 22c279881239..1165c4f48bc6 100644
--- a/Scheduler_Alert/run.ps1
+++ b/Scheduler_Alert/run.ps1
@@ -1,12 +1,13 @@
param($tenant)
$Table = Get-CIPPTable -Table SchedulerConfig
if ($Tenant.tag -eq 'AllTenants') {
- $Alerts = Get-AzTableRow -Table $table -RowKey 'AllTenants' -PartitionKey 'Alert'
+ $Filter = "RowKey eq 'AllTenants' and PartitionKey eq 'Alert'"
}
else {
- $Alerts = Get-AzTableRow -Table $table -RowKey $Tenant.tenantid -PartitionKey 'Alert'
-
+ $Filter = "RowKey eq '{0}' and PartitionKey eq 'Alert'" -f $Tenant.tenantid
}
+$Alerts = Get-AzDataTableEntity @Table -Filter $Filter
+
$DeltaTable = Get-CIPPTable -Table DeltaCompare
$LastRunTable = Get-CIPPTable -Table AlertLastRun
@@ -95,7 +96,8 @@ $ShippedAlerts = switch ($Alerts) {
{ $_.'NewRole' -eq $true } {
try {
- $AdminDelta = (Get-AzTableRow -Table $Deltatable -RowKey $Tenant.tenantid -PartitionKey 'AdminDelta').delta | ConvertFrom-Json -ErrorAction SilentlyContinue
+ $Filter = "PartitionKey eq 'AdminDelta' and RowKey eq '{0}'" -f $Tenant.tenantid
+ $AdminDelta = (Get-AzDataTableEntity @Deltatable -Filter $Filter).delta | ConvertFrom-Json -ErrorAction SilentlyContinue
$NewDelta = (New-GraphGetRequest -uri "https://graph.microsoft.com/beta/directoryRoles?`$expand=members" -tenantid $Tenant.tenant) | Select-Object displayname, Members | ForEach-Object {
[PSCustomObject]@{
GroupName = $_.displayname
@@ -103,7 +105,12 @@ $ShippedAlerts = switch ($Alerts) {
}
}
$NewDeltatoSave = $NewDelta | ConvertTo-Json -Depth 10 -Compress -ErrorAction SilentlyContinue
- $null = Add-AzTableRow -Table $DeltaTable -PartitionKey 'AdminDelta' -RowKey $Tenant.tenantid -property @{delta = $NewDeltatoSave } -UpdateExisting
+ $DeltaEntity = @{
+ PartitionKey = 'AdminDelta'
+ RowKey = $Tenant.tenantid
+ delta = $NewDeltatoSave
+ }
+ Add-AzDataTableEntity @DeltaTable -Entity $DeltaEntity -Force
if ($AdminDelta) {
foreach ($Group in $NewDelta) {
@@ -133,7 +140,8 @@ $ShippedAlerts = switch ($Alerts) {
{ $_.'UnusedLicenses' -eq $true } {
try {
#$ConvertTable = Import-Csv Conversiontable.csv
- $ExcludedSkuList = Get-AzTableRow -Table (Get-CIPPTable -TableName ExcludedLicenses)
+ $LicenseTable = Get-CIPPTable -TableName ExcludedLicenses
+ $ExcludedSkuList = Get-AzDataTableEntity @LicenseTable
New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/subscribedSkus' -tenantid $Tenant.tenant | ForEach-Object {
$skuid = $_
foreach ($sku in $skuid) {
@@ -153,8 +161,9 @@ $ShippedAlerts = switch ($Alerts) {
}
{ $_.'AppSecretExpiry' -eq $true } {
try {
- $LastRun = Get-AzTableRow -Table $LastRunTable -RowKey 'AppSecretExpiry' -PartitionKey $Tenant.tenantid
- if ($null -eq $LastRun.TableTimestamp -or ($LastRun.TableTimestamp -lt (Get-Date).AddDays(-1))) {
+ $Filter = "RowKey eq 'AppSecretExpiry' and PartitionKey eq '{0}'" -f $Tenant.tenantid
+ $LastRun = Get-AzDataTableEntity @LastRunTable -Filter $Filter
+ if ($null -eq $LastRun.Timestamp -or ($LastRun.Timestamp -lt (Get-Date).AddDays(-1))) {
New-GraphGetRequest -uri "https://graph.microsoft.com/beta/applications?`$select=appId,displayName,passwordCredentials" -tenantid $Tenant.tenant | ForEach-Object {
foreach ($App in $_) {
if ($App.passwordCredentials) {
@@ -166,7 +175,11 @@ $ShippedAlerts = switch ($Alerts) {
}
}
}
- $null = Add-AzTableRow -Table $LastRunTable -RowKey 'AppSecretExpiry' -PartitionKey $Tenant.tenantid -UpdateExisting
+ $LastRun = @{
+ RowKey = 'AppSecretExpiry'
+ PartitionKey = $Tenant.tenantid
+ }
+ Add-AzDataTableEntity @LastRunTable -Entity $LastRun -Force
}
}
catch {
@@ -177,11 +190,12 @@ $ShippedAlerts = switch ($Alerts) {
$Table = Get-CIPPTable
$PartitionKey = Get-Date -UFormat '%Y%m%d'
-$currentlog = Get-AzTableRow -Table $table -PartitionKey $PartitionKey
+$Filter = "PartitionKey eq '{0}'" -f $PartitionKey
+$currentlog = Get-AzDataTableEntity @Table -Filter $Filter
$ShippedAlerts | ForEach-Object {
if ($_ -notin $currentlog.Message) {
- Log-Request -message $_ -API 'Alerts' -tenant $tenant.tenant -sev Alert
+ Write-LogMessage -message $_ -API 'Alerts' -tenant $tenant.tenant -sev Alert
}
}
[PSCustomObject]@{
diff --git a/Scheduler_CIPPNotifications/run.ps1 b/Scheduler_CIPPNotifications/run.ps1
index 85fcc7df2b3d..a5269d102e36 100644
--- a/Scheduler_CIPPNotifications/run.ps1
+++ b/Scheduler_CIPPNotifications/run.ps1
@@ -4,17 +4,19 @@ param($tenant)
$currentUTCtime = (Get-Date).ToUniversalTime()
$Table = Get-CIPPTable -TableName SchedulerConfig
-$Config = Get-AzTableRow -Table $table -RowKey CippNotifications -PartitionKey CippNotifications
+$Filter = "RowKey eq 'CippNotifications' and PartitionKey eq 'CippNotifications'"
+$Config = Get-AzDataTableEntity @Table -Filter $Filter
-$Settings = [System.Collections.ArrayList]@("Alerts")
+$Settings = [System.Collections.ArrayList]@('Alerts')
$Config.psobject.properties.name | ForEach-Object { $settings.add($_) }
$Table = Get-CIPPTable
$PartitionKey = Get-Date -UFormat '%Y%m%d'
-$Currentlog = Get-AzTableRow -Table $table -PartitionKey $PartitionKey | Where-Object { $_.api -In $Settings -and $_.SentAsAlert -ne $true }
+$Filter = "PartitionKey eq '{0}'" -f $PartitionKey
+$Currentlog = Get-AzDataTableEntity @Table -Filter $Filter | Where-Object { $_.api -In $Settings -and $_.SentAsAlert -ne $true }
try {
- if ($Config.email -like "*@*" -and $null -ne $CurrentLog) {
+ if ($Config.email -like '*@*' -and $null -ne $CurrentLog) {
$HTMLLog = ($CurrentLog | Select-Object Message, API, Tenant, Username, Severity | ConvertTo-Html -frag) -replace '', '' | Out-String
$JSONBody = @"
{
@@ -71,12 +73,17 @@ try {
}
Write-Host ($currentLog | ConvertTo-Json)
- $CurrentLog | ForEach-Object { $_.SentAsAlert = $true; $_ | Update-AzTableRow -Table $Table }
+ $UpdateLogs = $CurrentLog | ForEach-Object {
+ $_.SentAsAlert = $true
+ $_
+ }
+
+ Add-AzDataTableEntity @Table -Entity $UpdateLogs -Force
}
catch {
Write-Host "$($_.Exception.message)"
- Log-request -API "Alerts" -message "Could not send alerts: $($_.Exception.message)" -sev info
+ Write-LogMessage -API 'Alerts' -message "Could not send alerts: $($_.Exception.message)" -sev info
}
[PSCustomObject]@{
diff --git a/Scheduler_GetQueue/run.ps1 b/Scheduler_GetQueue/run.ps1
index 23844e23418d..ad9107982c55 100644
--- a/Scheduler_GetQueue/run.ps1
+++ b/Scheduler_GetQueue/run.ps1
@@ -1,23 +1,23 @@
param($name)
$Table = Get-CIPPTable -TableName SchedulerConfig
-$Tenants = Get-AzTableRow -Table $table
+$Tenants = Get-AzDataTableEntity @Table
$object = foreach ($Tenant in $tenants) {
- if ($Tenant.Tenant -ne "AllTenants") {
+ if ($Tenant.Tenant -ne 'AllTenants') {
[pscustomobject]@{
Tenant = $Tenant.Tenant
- Tag = "SingleTenant"
+ Tag = 'SingleTenant'
TenantID = $Tenant.tenantId
Type = $Tenant.Type
}
}
else {
- Write-Host "All tenants, doing them all"
+ Write-Host 'All tenants, doing them all'
get-tenants | ForEach-Object {
[pscustomobject]@{
Tenant = $_.defaultDomainName
- Tag = "AllTenants"
+ Tag = 'AllTenants'
TenantID = $_.customerId
Type = $Tenant.Type
}
diff --git a/Scheduler_Orchestration/run.ps1 b/Scheduler_Orchestration/run.ps1
index a569c27af1c7..5ba8de9cf849 100644
--- a/Scheduler_Orchestration/run.ps1
+++ b/Scheduler_Orchestration/run.ps1
@@ -20,5 +20,5 @@ try {
}
catch {}
finally {
- Log-request -API 'Scheduler' -tenant $tenant -message 'Scheduler Ran.' -sev Debug
+ Write-LogMessage -API 'Scheduler' -tenant $tenant -message 'Scheduler Ran.' -sev Debug
}
\ No newline at end of file
diff --git a/SecurityBaselines_All/run.ps1 b/SecurityBaselines_All/run.ps1
index a4862f7e8b17..bb5abcf44ab9 100644
--- a/SecurityBaselines_All/run.ps1
+++ b/SecurityBaselines_All/run.ps1
@@ -1,4 +1,4 @@
param($tenant)
-#Log-request -API "SecurityBaselines" -tenant $tenant -message "SecurityBaselines_All called at $((Get-Date).tofiletime())" -sev Info
+#Write-LogMessage -API "SecurityBaselines" -tenant $tenant -message "SecurityBaselines_All called at $((Get-Date).tofiletime())" -sev Info
Write-Output $tenant.defaultDomainName
diff --git a/SecurityBaselines_Orchestration/run.ps1 b/SecurityBaselines_Orchestration/run.ps1
index 5f15b2ea36e0..c62c10bfcecd 100644
--- a/SecurityBaselines_Orchestration/run.ps1
+++ b/SecurityBaselines_Orchestration/run.ps1
@@ -1,6 +1,6 @@
param($Context)
-Log-request -API "SecurityBaselines" -tenant $tenant -message "SecurityBaselines_Orchestration called at $((Get-Date).tofiletime())" -sev Info
+Write-LogMessage -API "SecurityBaselines" -tenant $tenant -message "SecurityBaselines_Orchestration called at $((Get-Date).tofiletime())" -sev Info
#Remove-Item "SecurityBaselines_All\results.json" -Force
New-Item "SecurityBaselines_All\CurrentlyRunning.txt" -ItemType File -Force
@@ -9,9 +9,9 @@ $ParallelTasks = foreach ($Item in $Batch) {
Invoke-DurableActivity -FunctionName "SecurityBaselines_All" -Input $item -NoWait
}
-Log-request -API "SecurityBaselines" -tenant $tenant -message "STARTING PROCESS OF OUTPUTS!" -sev Info
+Write-LogMessage -API "SecurityBaselines" -tenant $tenant -message "STARTING PROCESS OF OUTPUTS!" -sev Info
$Outputs = Wait-ActivityFunction -Task $ParallelTasks
-Log-request -API "SecurityBaselines" -tenant $tenant -message "Outputs found count = $($Outputs.count)" -sev Info
+Write-LogMessage -API "SecurityBaselines" -tenant $tenant -message "Outputs found count = $($Outputs.count)" -sev Info
foreach ($item in $Outputs) {
Write-Host $Item | Out-String
@@ -20,5 +20,5 @@ foreach ($item in $Outputs) {
Set-Content "SecurityBaselines_All\results.json" -Value $Object -Force
}
-#Log-request -API "DomainAnalyser" -tenant $tenant -message "Domain Analyser has Finished" -sev Info
+#Write-LogMessage -API "DomainAnalyser" -tenant $tenant -message "Domain Analyser has Finished" -sev Info
Remove-Item "SecurityBaselines_All\CurrentlyRunning.txt" -Force
\ No newline at end of file
diff --git a/SecurityBaselines_OrchestrationStarter/run.ps1 b/SecurityBaselines_OrchestrationStarter/run.ps1
index b94c58e14fd2..19e14dcfdf26 100644
--- a/SecurityBaselines_OrchestrationStarter/run.ps1
+++ b/SecurityBaselines_OrchestrationStarter/run.ps1
@@ -1,14 +1,14 @@
using namespace System.Net
param($Request, $TriggerMetadata)
-Log-request -API "SecurityBaselines" -tenant $tenant -message "SecurityBaselines_OrchestrationStarter called at $(Get-Date)" -sev Info
+Write-LogMessage -API "SecurityBaselines" -tenant $tenant -message "SecurityBaselines_OrchestrationStarter called at $(Get-Date)" -sev Info
$APIName = $TriggerMetadata.FunctionName
$OrchestratorName = "SecurityBaselines_Orchestration"
$CurrentlyRunning = Get-Item "SecurityBaselines_All\CurrentlyRunning.txt" -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-24)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{"Results" = "Already running. Please wait for the current instance to finish" }
- Log-request -API $APIName -message "Attempted to start an instance but an instance was already running." -sev Info
+ Write-LogMessage -API $APIName -message "Attempted to start an instance but an instance was already running." -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName $OrchestratorName
diff --git a/Standards_ActivityBasedTimeout/run.ps1 b/Standards_ActivityBasedTimeout/run.ps1
index 3e0efc8b34f4..849f9c6e7ab7 100644
--- a/Standards_ActivityBasedTimeout/run.ps1
+++ b/Standards_ActivityBasedTimeout/run.ps1
@@ -11,8 +11,8 @@ try {
"@
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/policies/activityBasedTimeoutPolicies" -Type POST -Body $body -ContentType "application/json")
}
- Log-request -API "Standards" -tenant $tenant -message "Enabled Activity Based Timeout of one hour" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Enabled Activity Based Timeout of one hour" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to enable Activity Based Timeout $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to enable Activity Based Timeout $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_AnonReportDisable/run.ps1 b/Standards_AnonReportDisable/run.ps1
index 246bf1883a0d..489aac55fd43 100644
--- a/Standards_AnonReportDisable/run.ps1
+++ b/Standards_AnonReportDisable/run.ps1
@@ -11,8 +11,8 @@ try {
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
}
- Log-request -API "Standards" -tenant $tenant -message "Anonymous Reports Disabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Anonymous Reports Disabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable anonymous reports. Error: $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable anonymous reports. Error: $($_.exception.message)"
}
\ No newline at end of file
diff --git a/Standards_AuditLog/run.ps1 b/Standards_AuditLog/run.ps1
index c3a46cdc0005..9dc63ae43774 100644
--- a/Standards_AuditLog/run.ps1
+++ b/Standards_AuditLog/run.ps1
@@ -10,9 +10,9 @@ try {
UnifiedAuditLogIngestionEnabled = $true
}
New-ExoRequest -tenantid $Tenant -cmdlet "Set-AdminAuditLogConfig" -cmdParams $AdminAuditLogParams
- Log-request -API "Standards" -tenant $tenant -message "Unified Audit Log Enabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Unified Audit Log Enabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to apply Unified Audit Log. Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to apply Unified Audit Log. Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_AutoExpandArchive/run.ps1 b/Standards_AutoExpandArchive/run.ps1
index bda194a4669b..93746b7e1dad 100644
--- a/Standards_AutoExpandArchive/run.ps1
+++ b/Standards_AutoExpandArchive/run.ps1
@@ -2,9 +2,9 @@ param($tenant)
try {
New-ExoRequest -tenantid $Tenant -cmdlet "Set-OrganizationConfig" -cmdParams @{AutoExpandingArchive = $true }
- Log-request -API "Standards" -tenant $tenant -message "Added Auto Expanding Archive." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Added Auto Expanding Archive." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to apply Auto Expanding Archives Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to apply Auto Expanding Archives Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_AzurePortal/run.ps1 b/Standards_AzurePortal/run.ps1
index 4ed64e52c763..da8c27aa87cf 100644
--- a/Standards_AzurePortal/run.ps1
+++ b/Standards_AzurePortal/run.ps1
@@ -12,8 +12,8 @@ try {
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
}
- Log-request -API "Standards" -tenant $tenant -message "Azure AD Portal access for users disabled" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Azure AD Portal access for users disabled" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable user access to Azure Portal $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable user access to Azure Portal $($_.exception.message)"
}
\ No newline at end of file
diff --git a/Standards_DelegateSentItems/run.ps1 b/Standards_DelegateSentItems/run.ps1
index 7a7fccf7fa0c..d9e3364651f7 100644
--- a/Standards_DelegateSentItems/run.ps1
+++ b/Standards_DelegateSentItems/run.ps1
@@ -7,11 +7,11 @@ try {
New-ExoRequest -tenantid $Tenant -cmdlet "set-mailbox" -cmdParams @{Identity = $_.GUID ; MessageCopyForSendOnBehalfEnabled = $True; MessageCopyForSentAsEnabled = $True }
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Could not enable delegate sent item style for $($username): $($_.Exception.message)" -sev Warn
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Could not enable delegate sent item style for $($username): $($_.Exception.message)" -sev Warn
}
}
- Log-request -API "Standards" -tenant $tenant -message "Delegate Sent Items Style enabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Delegate Sent Items Style enabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to apply Delegate Sent Items Style. Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to apply Delegate Sent Items Style. Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_DeletedUserRentention/run.ps1 b/Standards_DeletedUserRentention/run.ps1
index c4c8ae4e78a4..e4b6e31f2842 100644
--- a/Standards_DeletedUserRentention/run.ps1
+++ b/Standards_DeletedUserRentention/run.ps1
@@ -4,8 +4,8 @@ try {
$body = '{"deletedUserPersonalSiteRetentionPeriodInDays": 365}'
New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/admin/sharepoint/settings" -AsApp $true -Type PATCH -Body $body -ContentType "application/json"
- Log-request -API "Standards" -tenant $tenant -message "Set deleted user rentention of OneDrive to 1 year" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Set deleted user rentention of OneDrive to 1 year" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to set deleted user rentention of OneDrive to 1 year: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to set deleted user rentention of OneDrive to 1 year: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_DisableBasicAuth/run.ps1 b/Standards_DisableBasicAuth/run.ps1
index 68cd27d736f1..1fa0a4254135 100644
--- a/Standards_DisableBasicAuth/run.ps1
+++ b/Standards_DisableBasicAuth/run.ps1
@@ -11,8 +11,8 @@ try {
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
}
- Log-request -API "Standards" -tenant $tenant -message "Basic Authentication Disabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Basic Authentication Disabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable Basic Authentication Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable Basic Authentication Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_DisableM365GroupUsers/run.ps1 b/Standards_DisableM365GroupUsers/run.ps1
index f9852998852b..08758135b0b2 100644
--- a/Standards_DisableM365GroupUsers/run.ps1
+++ b/Standards_DisableM365GroupUsers/run.ps1
@@ -5,8 +5,8 @@ try {
($CurrentState.values | Where-Object { $_.name -eq 'EnableGroupCreation' }).value = "false"
$body = "{values : $($CurrentState.values | ConvertTo-Json -Compress)}"
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/settings/$($CurrentState.id)" -Type patch -Body $body -ContentType "application/json")
- Log-request -API "Standards" -tenant $tenant -message "Standards API: Disabled users from creating Security Groups." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Standards API: Disabled users from creating Security Groups." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable users from creating Security Groups: $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable users from creating Security Groups: $($_.exception.message)"
}
diff --git a/Standards_DisableReshare/run.ps1 b/Standards_DisableReshare/run.ps1
index 5a3613438eaa..c65deac5baea 100644
--- a/Standards_DisableReshare/run.ps1
+++ b/Standards_DisableReshare/run.ps1
@@ -6,8 +6,8 @@ try {
$Request = New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/admin/sharepoint/settings" -AsApp $true -Type patch -Body $body -ContentType "application/json"
Write-Host "Here's Johnny"
Write-Host ($Request | ConvertTo-Json)
- Log-request -API "Standards" -tenant $tenant -message "Disabled guests from resharing files" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Disabled guests from resharing files" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable guests from resharing files: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable guests from resharing files: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_DisableSecurityGroupUsers/run.ps1 b/Standards_DisableSecurityGroupUsers/run.ps1
index 8765158ce617..bfc3fd3aa395 100644
--- a/Standards_DisableSecurityGroupUsers/run.ps1
+++ b/Standards_DisableSecurityGroupUsers/run.ps1
@@ -4,8 +4,8 @@ try {
$body = '{"defaultUserRolePermissions":{"allowedToCreateSecurityGroups":false}}'
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy" -Type patch -Body $body -ContentType "application/json")
- Log-request -API "Standards" -tenant $tenant -message "Standards API: Disabled users from creating Security Groups." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Standards API: Disabled users from creating Security Groups." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable users from creating Security Groups: $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable users from creating Security Groups: $($_.exception.message)"
}
diff --git a/Standards_DisableSelfServiceLicenses/run.ps1 b/Standards_DisableSelfServiceLicenses/run.ps1
index 54922bd2b671..2ed663f5cb9c 100644
--- a/Standards_DisableSelfServiceLicenses/run.ps1
+++ b/Standards_DisableSelfServiceLicenses/run.ps1
@@ -12,9 +12,9 @@ try {
http://provisioning.microsoftonline.com/IProvisioningWebService/SetCompanySettingsurn:uuid:$TrackingGuidhttp://www.w3.org/2005/08/addressing/anonymous$($AADGraphtoken['Authorization'])$DataBlob250afce61-c917-435b-8c6d-60aa5a8b8aa71.2.183.57Version474e6cb653-c968-4a3a-8a11-2c8919218aebhttps://provisioningapi.microsoftonline.com/provisioningwebservice.svcVersion16false
"@
$DisableSelfService = (Invoke-RestMethod -Uri "https://provisioningapi.microsoftonline.com/provisioningwebservice.svc" -Method post -Body $DisableSelfServiceBody -ContentType 'application/soap+xml; charset=utf-8')
- Log-request "Standards API: $($tenant) Disabled Self Service for licenses" -sev Info
+ Write-LogMessage "Standards API: $($tenant) Disabled Self Service for licenses" -sev Info
}
catch {
- Log-request "Standards API: $($tenant) failed to disable License Buy Self Service: $($exception.message)" -sev Error
+ Write-LogMessage "Standards API: $($tenant) failed to disable License Buy Self Service: $($exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_DisableSharedMailbox/run.ps1 b/Standards_DisableSharedMailbox/run.ps1
index 003832b92dd9..9e73df2cbb7a 100644
--- a/Standards_DisableSharedMailbox/run.ps1
+++ b/Standards_DisableSharedMailbox/run.ps1
@@ -4,9 +4,9 @@ try {
$SharedMailboxList = (New-GraphGetRequest -uri "https://outlook.office365.com/adminapi/beta/$($tenant)/Mailbox" -Tenantid $tenant -scope ExchangeOnline | Where-Object -propert RecipientTypeDetails -EQ "SharedMailbox") | ForEach-Object {
New-GraphPOSTRequest -uri "https://graph.microsoft.com/v1.0/users/$($_.ObjectKey)" -type "PATCH" -body '{"accountEnabled":"false"}' -tenantid $tenant
}
- Log-request -API "Standards" -tenant $tenant -message "AAD Accounts for shared mailboxes disabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "AAD Accounts for shared mailboxes disabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable AAD accounts for shared mailboxes. Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable AAD accounts for shared mailboxes. Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_DisableUserSiteCreate/run.ps1 b/Standards_DisableUserSiteCreate/run.ps1
index 07aba3fb9452..3cb87b68e47d 100644
--- a/Standards_DisableUserSiteCreate/run.ps1
+++ b/Standards_DisableUserSiteCreate/run.ps1
@@ -3,8 +3,8 @@
try {
$body = '{"isSiteCreationEnabled": false}'
New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/admin/sharepoint/settings" -AsApp $true -Type patch -Body $body -ContentType "application/json"
- Log-request -API "Standards" -tenant $tenant -message "Disabled standard users from creating sites" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Disabled standard users from creating sites" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable standard users from creating sites: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable standard users from creating sites: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_DisableViva/run.ps1 b/Standards_DisableViva/run.ps1
index 70f9f4d5a4ee..89b50ec0dd62 100644
--- a/Standards_DisableViva/run.ps1
+++ b/Standards_DisableViva/run.ps1
@@ -4,9 +4,9 @@ try {
$MailboxesNoArchive = (New-ExoRequest -tenantid $tenant -cmdlet "get-mailbox" -cmdparams @{ Filter = 'RecipientTypeDetails -Eq "UserMailbox"' }) | ForEach-Object {
(New-ExoRequest -tenantid $tenant -cmdlet "Set-UserBriefingConfig" -cmdparams @{ Identity = $_.UserPrincipalName; Enabled = $false })
}
- Log-request -API "Standards" -tenant $tenant -message "Disable daily Viva reports" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Disable daily Viva reports" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable Viva for all users Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable Viva for all users Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_EnableOnlineArchiving/run.ps1 b/Standards_EnableOnlineArchiving/run.ps1
index 91d9178f8211..7ab5ad7a6d98 100644
--- a/Standards_EnableOnlineArchiving/run.ps1
+++ b/Standards_EnableOnlineArchiving/run.ps1
@@ -4,9 +4,9 @@ try {
$MailboxesNoArchive = (New-ExoRequest -tenantid $tenant -cmdlet "get-mailbox" -cmdparams @{ Filter = 'ArchiveGuid -Eq "00000000-0000-0000-0000-000000000000" -AND RecipientTypeDetails -Eq "UserMailbox"' }) | ForEach-Object {
(New-ExoRequest -tenantid $tenant -cmdlet "enable-Mailbox" -cmdparams @{ Identity = $_.Guid; Archive = $true })
}
- Log-request -API "Standards" -tenant $tenant -message "Enabled Online Archiving for all accounts" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Enabled Online Archiving for all accounts" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to Enable Online Archiving for all accounts Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to Enable Online Archiving for all accounts Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_ExcludedfileExt/run.ps1 b/Standards_ExcludedfileExt/run.ps1
index 759d21e55219..daa47d66d102 100644
--- a/Standards_ExcludedfileExt/run.ps1
+++ b/Standards_ExcludedfileExt/run.ps1
@@ -9,8 +9,8 @@ try {
$Exts = $Setting.ext -split ','
$body = ConvertTo-Json -InputObject @{ excludedFileExtensionsForSyncApp = @($Exts) }
New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/admin/sharepoint/settings" -AsApp $true -Type patch -Body $body -ContentType "application/json"
- Log-request -API "Standards" -tenant $tenant -message "Added $($Setting.ext) to excluded synced files" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Added $($Setting.ext) to excluded synced files" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to add $($Setting.ext) to excluded synced files: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to add $($Setting.ext) to excluded synced files: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_LegacyMFA/run.ps1 b/Standards_LegacyMFA/run.ps1
index 90075681b47a..d06befed3a11 100644
--- a/Standards_LegacyMFA/run.ps1
+++ b/Standards_LegacyMFA/run.ps1
@@ -16,9 +16,9 @@ try {
"@
$SetMFA = (Invoke-RestMethod -Uri "https://provisioningapi.microsoftonline.com/provisioningwebservice.svc" -Method post -Body $MSOLXML -ContentType 'application/soap+xml; charset=utf-8')
}
- Log-request -API "Standards" -tenant $tenant -message "Enabled per user MFA." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Enabled per user MFA." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to enable (legacy) per user MFA: $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to enable (legacy) per user MFA: $($_.exception.message)"
}
\ No newline at end of file
diff --git a/Standards_MailContacts/run.ps1 b/Standards_MailContacts/run.ps1
index 0283540031c7..e0062f5cc4ec 100644
--- a/Standards_MailContacts/run.ps1
+++ b/Standards_MailContacts/run.ps1
@@ -16,8 +16,8 @@ try {
}
Write-Host (ConvertTo-Json -InputObject $body)
New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/organization/$($TenantID.id)" -Type patch -Body (ConvertTo-Json -InputObject $body) -ContentType "application/json"
- Log-request -API "Standards" -tenant $tenant -message "Contact email's set." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Contact email's set." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to set contact emails: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to set contact emails: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_ModernAuth/run.ps1 b/Standards_ModernAuth/run.ps1
index 85fd6b40566c..78a4db9a75d1 100644
--- a/Standards_ModernAuth/run.ps1
+++ b/Standards_ModernAuth/run.ps1
@@ -4,8 +4,8 @@ try {
$currentStatus = New-ClassicAPIGetRequest -Uri "https://admin.microsoft.com/admin/api/services/apps/modernAuth" -TenantID $tenant
$currentStatus.EnableModernAuth = $true
$ModernAuthRequest = New-ClassicAPIPostRequest -Uri 'https://admin.microsoft.com/admin/api/services/apps/modernAuth' -Body ($currentStatus | ConvertTo-Json) -Method POST -TenantID $tenant
- Log-request -API "Standards" -tenant $tenant -message "Modern Authentication enabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Modern Authentication enabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to enable Modern Authentication. Error: $($_.exception.message)" -sev "Error"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to enable Modern Authentication. Error: $($_.exception.message)" -sev "Error"
}
\ No newline at end of file
diff --git a/Standards_OauthConsent/run.ps1 b/Standards_OauthConsent/run.ps1
index 58614a7a3610..ceb14111f355 100644
--- a/Standards_OauthConsent/run.ps1
+++ b/Standards_OauthConsent/run.ps1
@@ -30,8 +30,8 @@ try {
if ($AllowedAppIdsForTenant) {
}
- Log-request -API "Standards" -tenant $tenant -message "Application Consent Mode has been enabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Application Consent Mode has been enabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to apply Application Consent Mode Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to apply Application Consent Mode Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_Orchestration/run.ps1 b/Standards_Orchestration/run.ps1
index 7e53307df97b..2bc47f783146 100644
--- a/Standards_Orchestration/run.ps1
+++ b/Standards_Orchestration/run.ps1
@@ -15,9 +15,9 @@ try {
}
}
catch {
- Log-request -API 'Standards' -tenant $tenant -message "Orchestrator error: $($_.Exception.Message)" -sev Info
+ Write-LogMessage -API 'Standards' -tenant $tenant -message "Orchestrator error: $($_.Exception.Message)" -sev Info
}
finally {
- Log-request -API 'Standards' -tenant $tenant -message 'Deployment finished.' -sev Info
+ Write-LogMessage -API 'Standards' -tenant $tenant -message 'Deployment finished.' -sev Info
Remove-Item 'Cache_Standards\CurrentlyRunning.txt' -Force
}
diff --git a/Standards_OrchestrationStarter/run.ps1 b/Standards_OrchestrationStarter/run.ps1
index 5904cdd3a1b5..64eb2897bc16 100644
--- a/Standards_OrchestrationStarter/run.ps1
+++ b/Standards_OrchestrationStarter/run.ps1
@@ -4,14 +4,14 @@ param($Request, $TriggerMetadata)
$CurrentlyRunning = Get-Item "Cache_Standards\CurrentlyRunning.txt" -ErrorAction SilentlyContinue | Where-Object -Property LastWriteTime -GT (Get-Date).AddHours(-4)
if ($CurrentlyRunning) {
$Results = [pscustomobject]@{"Results" = "Already running. Please wait for the current instance to finish" }
- Log-request -API "StandardsApply" -message "Attempted to Standards but an instance was already running." -sev Info
+ Write-LogMessage -API "StandardsApply" -message "Attempted to Standards but an instance was already running." -sev Info
}
else {
$InstanceId = Start-NewOrchestration -FunctionName 'Standards_Orchestration'
Write-Host "Started orchestration with ID = '$InstanceId'"
$Response = New-OrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId
Write-Host ($Response | ConvertTo-Json)
- Log-request -API "Standards" -tenant $tenant -message "Started applying the standard templates to tenants." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Started applying the standard templates to tenants." -sev Info
$Results = [pscustomobject]@{"Results" = "Started Applying Standards" }
}
Write-Host ($Orchestrator | ConvertTo-Json)
diff --git a/Standards_OrchestrationStarterTimer/run.ps1 b/Standards_OrchestrationStarterTimer/run.ps1
index 891edf8930a2..4fa90a9e8720 100644
--- a/Standards_OrchestrationStarterTimer/run.ps1
+++ b/Standards_OrchestrationStarterTimer/run.ps1
@@ -7,4 +7,4 @@ Write-Host "Started orchestration with ID = '$InstanceId'"
$Response = New-OrchestrationCheckStatusResponse -Request $timer -InstanceId $InstanceId
Write-Host ($Response | ConvertTo-Json)
-Log-request -API "Standards" -tenant $tenant -message "Started applying the standard templates to tenants." -sev Info
+Write-LogMessage -API "Standards" -tenant $tenant -message "Started applying the standard templates to tenants." -sev Info
diff --git a/Standards_PWdisplayAppInformationRequiredState/run.ps1 b/Standards_PWdisplayAppInformationRequiredState/run.ps1
index 53a27f6406bd..7058b8cde9bf 100644
--- a/Standards_PWdisplayAppInformationRequiredState/run.ps1
+++ b/Standards_PWdisplayAppInformationRequiredState/run.ps1
@@ -6,8 +6,8 @@ try {
"@
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations/microsoftAuthenticator" -Type patch -Body $body -ContentType "application/json")
- Log-request -API "Standards" -tenant $tenant -message "Enabled passwordless with Information and Number Matching." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Enabled passwordless with Information and Number Matching." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to enable passwordless with Information and Number Matching. Error: $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to enable passwordless with Information and Number Matching. Error: $($_.exception.message)"
}
\ No newline at end of file
diff --git a/Standards_PWnumberMatchingRequiredState/run.ps1 b/Standards_PWnumberMatchingRequiredState/run.ps1
index 5fe0c060aa0e..f50649fe5a0b 100644
--- a/Standards_PWnumberMatchingRequiredState/run.ps1
+++ b/Standards_PWnumberMatchingRequiredState/run.ps1
@@ -6,8 +6,8 @@ try {
"@
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations/microsoftAuthenticator" -Type patch -Body $body -ContentType "application/json")
- Log-request -API "Standards" -tenant $tenant -message "Enabled passwordless with Number Matching." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Enabled passwordless with Number Matching." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to enable passwordless with Number Matching. Error: $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to enable passwordless with Number Matching. Error: $($_.exception.message)"
}
\ No newline at end of file
diff --git a/Standards_PasswordExpireDisabled/run.ps1 b/Standards_PasswordExpireDisabled/run.ps1
index 8ca1bdb21435..418680e784aa 100644
--- a/Standards_PasswordExpireDisabled/run.ps1
+++ b/Standards_PasswordExpireDisabled/run.ps1
@@ -5,8 +5,8 @@ try {
$body = "resource=https://admin.microsoft.com&grant_type=refresh_token&refresh_token=$($ENV:ExchangeRefreshToken)"
$token = Invoke-RestMethod $uri -Body $body -ContentType "application/x-www-form-urlencoded" -ErrorAction SilentlyContinue -method post
$PasswordExpire = Invoke-RestMethod -contenttype "application/json; charset=utf-8" -uri 'https://admin.microsoft.com/admin/api/Settings/security/passwordpolicy' -method POST -body '{"ValidityPeriod":900,"NotificationDays":140,"NeverExpire":true}' -Headers @{Authorization = "Bearer $($token.access_token)"; "x-ms-client-request-id" = [guid]::NewGuid().ToString(); "x-ms-client-session-id" = [guid]::NewGuid().ToString(); 'X-Requested-With' = 'XMLHttpRequest'; 'x-ms-correlation-id' = [guid]::NewGuid() }
- Log-request -API "Standards" -tenant $tenant -message "Disabled Password Expiration" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Disabled Password Expiration" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable Password Expiration. Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable Password Expiration. Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_SSPR/run.ps1 b/Standards_SSPR/run.ps1
index d3c60e7152c7..161d8539b168 100644
--- a/Standards_SSPR/run.ps1
+++ b/Standards_SSPR/run.ps1
@@ -12,8 +12,8 @@ try {
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
}
- Log-request -API "Standards" -tenant $tenant -message "SSPR enabled" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "SSPR enabled" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to enable SSPR $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to enable SSPR $($_.exception.message)"
}
\ No newline at end of file
diff --git a/Standards_SecurityDefaults/run.ps1 b/Standards_SecurityDefaults/run.ps1
index 685a8c7078a0..e3ed1c5476e6 100644
--- a/Standards_SecurityDefaults/run.ps1
+++ b/Standards_SecurityDefaults/run.ps1
@@ -8,8 +8,8 @@ try {
$body = '{ "isEnabled": true }'
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/policies/identitySecurityDefaultsEnforcementPolicy" -Type patch -Body $body -ContentType "application/json")
}
- Log-request -API "Standards" -tenant $tenant -message "Standards API: Security Defaults Enabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Standards API: Security Defaults Enabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to enable Security Defaults Error: $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to enable Security Defaults Error: $($_.exception.message)"
}
diff --git a/Standards_SendFromAlias/run.ps1 b/Standards_SendFromAlias/run.ps1
index 2091d5597fcb..1a6e45c06278 100644
--- a/Standards_SendFromAlias/run.ps1
+++ b/Standards_SendFromAlias/run.ps1
@@ -5,9 +5,9 @@ try {
SendFromAliasEnabled = $true
}
New-ExoRequest -tenantid $Tenant -cmdlet "Set-OrganizationConfig" -cmdParams $AdminAuditLogParams
- Log-request -API "Standards" -tenant $tenant -message "Send from alias Enabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Send from alias Enabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to apply Send from Alias Standard. Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to apply Send from Alias Standard. Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_SpoofWarn/run.ps1 b/Standards_SpoofWarn/run.ps1
index 5dd766363132..720880c44686 100644
--- a/Standards_SpoofWarn/run.ps1
+++ b/Standards_SpoofWarn/run.ps1
@@ -2,9 +2,9 @@ param($tenant)
try {
New-ExoRequest -tenantid $Tenant -cmdlet "Set-ExternalInOutlook" -cmdParams @{ Enabled = $true; }
- Log-request -API "Standards" -tenant $tenant -message "Spoofing warnings enabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Spoofing warnings enabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Could not enabled spoofing warnings. Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Could not enabled spoofing warnings. Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_TAP/run.ps1 b/Standards_TAP/run.ps1
index 7f5404c264aa..4a464230f9f0 100644
--- a/Standards_TAP/run.ps1
+++ b/Standards_TAP/run.ps1
@@ -20,8 +20,8 @@ try {
"@
(New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/policies/authenticationmethodspolicy/authenticationMethodConfigurations/TemporaryAccessPass" -Type patch -Body $body -ContentType "application/json")
- Log-request -API "Standards" -tenant $tenant -message "Enabled Temporary Access Passwords." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Enabled Temporary Access Passwords." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to enable TAP. Error: $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to enable TAP. Error: $($_.exception.message)"
}
\ No newline at end of file
diff --git a/Standards_UndoOauth/run.ps1 b/Standards_UndoOauth/run.ps1
index 7ce0a73bf0b0..b40017aa5586 100644
--- a/Standards_UndoOauth/run.ps1
+++ b/Standards_UndoOauth/run.ps1
@@ -11,8 +11,8 @@ try {
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
}
- Log-request -API "Standards" -tenant $tenant -message "Application Consent Mode has been disabled." -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Application Consent Mode has been disabled." -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to set Application Consent Mode to disabled Error: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to set Application Consent Mode to disabled Error: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_UndoSSPR/run.ps1 b/Standards_UndoSSPR/run.ps1
index 7e41abb2f94a..673d6c8fe89a 100644
--- a/Standards_UndoSSPR/run.ps1
+++ b/Standards_UndoSSPR/run.ps1
@@ -12,8 +12,8 @@ try {
'x-ms-correlation-id' = [guid]::NewGuid()
'X-Requested-With' = 'XMLHttpRequest'
}
- Log-request -API "Standards" -tenant $tenant -message "SSPR disabled" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "SSPR disabled" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable SSPR $($_.exception.message)"
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable SSPR $($_.exception.message)"
}
\ No newline at end of file
diff --git a/Standards_disableMacSync/run.ps1 b/Standards_disableMacSync/run.ps1
index 1161c2fea84a..232e6be61387 100644
--- a/Standards_disableMacSync/run.ps1
+++ b/Standards_disableMacSync/run.ps1
@@ -3,8 +3,8 @@
try {
$body = '{"isMacSyncAppEnabled": false}'
New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/admin/sharepoint/settings" -AsApp $true -Type patch -Body $body -ContentType "application/json"
- Log-request -API "Standards" -tenant $tenant -message "Disabled Mac OneDrive Sync" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Disabled Mac OneDrive Sync" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable Mac OneDrive Sync: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable Mac OneDrive Sync: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_sharingCapability/run.ps1 b/Standards_sharingCapability/run.ps1
index 8e458fba1294..520611e0df4a 100644
--- a/Standards_sharingCapability/run.ps1
+++ b/Standards_sharingCapability/run.ps1
@@ -7,8 +7,8 @@ if (!$Setting) { $Setting = (Get-Content ".\Cache_Standards\AllTenants.Standards
try {
New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/admin/sharepoint/settings" -AsApp $true -Type patch -Body "{`"sharingCapability`":`"$($Setting.Level)`"}" -ContentType "application/json"
- Log-request -API "Standards" -tenant $tenant -message "Set sharing level to $($Setting.level)" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Set sharing level to $($Setting.level)" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to set sharing level to $($Setting.level): $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to set sharing level to $($Setting.level): $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/Standards_unmanagedSync/run.ps1 b/Standards_unmanagedSync/run.ps1
index f1490a1d2071..a46d1bc146f5 100644
--- a/Standards_unmanagedSync/run.ps1
+++ b/Standards_unmanagedSync/run.ps1
@@ -3,8 +3,8 @@
try {
$body = '{"isUnmanagedSyncAppForTenantRestricted": false}'
New-GraphPostRequest -tenantid $tenant -Uri "https://graph.microsoft.com/beta/admin/sharepoint/settings" -AsApp $true -Type patch -Body $body -ContentType "application/json"
- Log-request -API "Standards" -tenant $tenant -message "Disabled Sync for unmanaged devices" -sev Info
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Disabled Sync for unmanaged devices" -sev Info
}
catch {
- Log-request -API "Standards" -tenant $tenant -message "Failed to disable Sync for unmanaged devices: $($_.exception.message)" -sev Error
+ Write-LogMessage -API "Standards" -tenant $tenant -message "Failed to disable Sync for unmanaged devices: $($_.exception.message)" -sev Error
}
\ No newline at end of file
diff --git a/UpdateTokens/run.ps1 b/UpdateTokens/run.ps1
index 24d8b71bc68e..36f9b417150f 100644
--- a/UpdateTokens/run.ps1
+++ b/UpdateTokens/run.ps1
@@ -17,13 +17,13 @@ $KV = $ENV:WEBSITE_DEPLOYMENT_ID
if ($Refreshtoken) {
Set-AzKeyVaultSecret -VaultName $kv -Name 'RefreshToken' -SecretValue (ConvertTo-SecureString -String $Refreshtoken -AsPlainText -Force)
}
-else { log-request -message "Could not update refresh token. Will try again in 7 days." -sev "CRITICAL" }
+else { Write-LogMessage -message "Could not update refresh token. Will try again in 7 days." -sev "CRITICAL" }
if ($ExchangeRefreshtoken -and $KV) {
Set-AzKeyVaultSecret -VaultName $kv -Name 'ExchangeRefreshToken' -SecretValue (ConvertTo-SecureString -String $ExchangeRefreshtoken -AsPlainText -Force)
- log-request -message "System API: Updated Exchange Refresh token." -sev "info" -API "TokensUpdater"
+ Write-LogMessage -message "System API: Updated Exchange Refresh token." -sev "info" -API "TokensUpdater"
}
else {
- log-request -message "Could not update Exchange refresh token. Will try again in 7 days." -sev "CRITICAL" -API "TokensUpdater"
+ Write-LogMessage -message "Could not update Exchange refresh token. Will try again in 7 days." -sev "CRITICAL" -API "TokensUpdater"
}
# Write an information log with the current time.
diff --git a/profile.ps1 b/profile.ps1
index c0b7033f1dd6..385bb5d6c169 100644
--- a/profile.ps1
+++ b/profile.ps1
@@ -12,8 +12,10 @@
# Authenticate with Azure PowerShell using MSI.
# Remove this if you are not planning on using MSI or Azure PowerShell.
Import-Module .\GraphHelper.psm1
-Disable-AzContextAutosave -Scope Process | Out-Null
-
+try {
+ Disable-AzContextAutosave -Scope Process | Out-Null
+}
+catch {}
# Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
# Enable-AzureRmAlias
diff --git a/requirements.psd1 b/requirements.psd1
index 4ccc1d0fec09..452f1b8639e2 100644
--- a/requirements.psd1
+++ b/requirements.psd1
@@ -4,10 +4,10 @@
@{
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
# To use the Az module in your function app, please uncomment the line below.
- 'Az.accounts' = '2.*'
- 'Az.Keyvault' = '3.*'
- 'Az.functions' = '3.*'
- 'Az.Resources' = '5.*'
- 'Az.Storage' = '4.*'
- 'AzTable' = '2.*'
+ 'Az.accounts' = '2.*'
+ 'Az.Keyvault' = '3.*'
+ 'Az.functions' = '3.*'
+ 'Az.Resources' = '5.*'
+ 'Az.Storage' = '4.*'
+ 'AzBobbyTables' = '2.*'
}