Skip to content

Instantly share code, notes, and snippets.

@kosuka-EMS
kosuka-EMS / EntraID_deviceAudit_Export.ps1
Last active July 2, 2024 01:02
This script uses the Get-MgAuditLogDirectoryAudit cmdlet in the Microsoft Graph PowerShell SDK to retrieve the audit log of changes to specific device properties from on the Entra ID and output them to a CSV file.
# Move to the directory for CSV output (replace the path freely)
cd C:\work
# Connect to Microsoft Graph
### Sign in using a global administrator
### A consent page for requesting access to Entra ID will be displayed
Connect-MgGraph -Scope "AuditLog.Read.All", "Directory.Read.All"
# Define the properties to be acquired
### Compliance state change: IsCompliant
@kosuka-EMS
kosuka-EMS / EntraID_reportOnlyFailure_Export.ps1
Last active May 29, 2024 02:48
This script retrieves sign-in logs from Entra ID that were blocked in report-only mode using the Get-MgAuditLogSignIn cmdlet from the Microsoft Graph PowerShell SDK. It outputs the logs into CSV files, grouped by conditional access policy names.
# Move to the directory for CSV output (replace the path as needed)
cd C:\work
# Connect to Microsoft Graph
### Sign in using a global administrator account
### The consent page for accessing Entra ID will be displayed
Connect-MgGraph -Scope "AuditLog.Read.All", "Directory.Read.All", "Policy.Read.All"
# Get the date and time for the past 24 hours
$last24Hours = (Get-Date).AddHours(-24).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
@kosuka-EMS
kosuka-EMS / example.ps1
Last active September 16, 2020 14:15
This ps1 script looks at the state of dsregcmd /status > DeviceState and Write-Outputs the state of HAADJ / AADJ. You can use this script in the [Intune Win32 Apps] - [Add a Requirement rule]. This allows you to deploy applications based on HAADJ /AADJ status.
Param([switch]$Is64Bit = $false)
Function Restart-As64BitProcess {
If ([System.Environment]::Is64BitProcess) { return }
$Invocation = $($MyInvocation.PSCommandPath)
if ($Invocation -eq $null) { return }
$sysNativePath = $psHome.ToLower().Replace("syswow64", "sysnative")
$proc = Start-Process "$sysNativePath\powershell.exe" -ArgumentList "-ex bypass -file `"$Invocation`" -Is64Bit" -WindowStyle Hidden -Wait -PassThru
return $proc
}
@kosuka-EMS
kosuka-EMS / Example Wi-Fi WPA3.mobileconfig
Created June 14, 2020 08:22
iOS Wi-Fi WPA3 mobile config profile ( iOS 13 or later)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>AutoJoin</key>
<true/>
<key>CaptiveBypass</key>
@kosuka-EMS
kosuka-EMS / example.txt
Created March 21, 2020 18:15
ip-api request example
let
Source = (#"IP Address" as text) => let
Source = Json.Document(Web.Contents("http://ip-api.com/json/" & #"IP Address")),
#"Converted to Table" = Record.ToTable(Source),
#"Transposed Table" = Table.Transpose(#"Converted to Table"),
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table")
in
#"Promoted Headers"
in
Source
@kosuka-EMS
kosuka-EMS / example.xml
Created November 9, 2019 21:20
Intune/Android Enterprise Work Profile/Wi-Fi Profile XML
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>"①プロファイルの名前(自由)"</name>
<SSIDConfig>
<SSID>
<hex>"①で設定した値を16進数で変換したもの"</hex>
<name>"②SSID"</name>
</SSID>
<nonBroadcast>false</nonBroadcast>
</SSIDConfig>
<connectionType>ESS</connectionType>