Category: Active Directory
-
KQL To Pull LogType, Resourcename, LogsVolume From LogAnalytics Workspace
union withsource=LogTable *| where TimeGenerated > ago(60d)| extend ResourceId = tostring(parse_json(tostring(_ResourceId)))| extend ResourceName = tostring(split(ResourceId, “/”)[8])| extend ResourceType = case(LogTable in (“Heartbeat”, “Perf”, “InsightsMetrics”, “Syslog”, “SecurityEvent”, “VMConnection”, “Update”), “Virtual Machine”,LogTable startswith “App”, “Application”,LogTable in (“CommonSecurityLog”, “AzureDiagnostics”), “Firewall”,“Other”)| summarizeLogCount = count(),IngestedVolumeMB = sum(_BilledSize) / 1024.0,TotalBilledVolumeMB = sum(_BilledSize) / 1024.0 // Same as IngestedVolumeMB unless raw size…
-
Get Members From Dynamic DLs in Office365
$FTE = Get-DynamicDistributionGroup “Branding Campaign Team”; Get-Recipient -RecipientPreviewFilter $FTE.RecipientFilter | Export -CSV “D:\DGList.csv” $FTE = Get-DynamicDistributionGroup “Branding Campaign Team”; Get-Recipient -RecipientPreviewFilter $FTE.RecipientFilter | Select Displayname
-
List Federated Microsoft Teams in Powershell
(Get-CsTenantFederationConfiguration).alloweddomains.alloweddomain
-
Get-MSOLUSERS MFA Status From Import-CSV
$UserPrincipalName=import-csv c:\temp\TEST-MFA-Enrolled.csv $UserPrincipalName.foreach( { Get-MsolUser -UserPrincipalName $_.Name | where {$_.StrongAuthenticationMethods -like “strong“} } ) | Export-Csv “C:\Temp\User-TO-BE-Added-EnrolledGroup.csv”
-
Install Application
#start the following Windows services in the specified order: [Array] $Services = ‘abc’,’abc’; #The KSASvcChk checks the status of both Kaseya services (Kaseya Agent:’KAKSAAS143744567159389′, Kaseya Agent Endpoint:’KAENDKSAAS143744567159389′) and outputs the status of both function KSASvcChk{ #Service Name paramater param($ServiceName) $arrService = Get-Service -Name $ServiceNameif ($arrService.Status -ne “Running”){Write $false}if ($arrService.Status -eq “running”){Write $true}else {Write $false}} #The…
-
Inheritance user permissions to all organizations Units recursively
OU –> Properties –> Security –> add user or group –>then click on user or group –> Advance –> select same account –> Applies to “This object and All Descendant Objects
-
Use Multiple Filters in Powershell
$ou=’OU=subou3,OU=subou2,OU=subou1,DC=domain,DC=com’$filter = @(“machinename1”, “machinename2”)$compute= Get-ADComputer -Filter * -SearchBase $ou | where-object{$filter -contains $_.name}
-
Start the services in Any windows machines
start the following Windows services in the specified order: [Array] $Services = ‘winrm’,’TermService’; loop through each service, if its not running, start it foreach($ServiceName in $Services){$arrService = Get-Service -Name $ServiceNamewrite-host $ServiceNamewhile ($arrService.Status -ne ‘Running’){Start-Service $ServiceNamewrite-host $arrService.statuswrite-host ‘Service starting’Start-Sleep -seconds 60$arrService.Refresh()if ($arrService.Status -eq ‘Running’){Write-Host ‘Service is now Running’}}}