This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requirements must be installed with the following. | |
# Usually the error is that azure.something is missing. | |
python3 -m pip install -r ~/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt | |
# Voila. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define time for report (default is 1 day) | |
$startDate = (get-date).AddDays(-1) | |
# Store successful logon events from security logs with the specified dates and workstation/IP in an array | |
# foreach ($DC in $DCs){ | |
# $slogonevents = Get-Eventlog -LogName Security -ComputerName $DC.Hostname -after $startDate | where {$_.eventID -eq 4624 } | |
# } | |
$slogonevents = Get-Eventlog -LogName Security -after $startDate | Where-Object {$_.eventID -eq 4624 } | |
Write-host $slogonevents.count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Empty array [] | |
- name: Loop through the application servers | |
win_hosts: | |
state: present | |
canonical_name: "{{ hostvars[item].inventory_hostname }}" | |
ip_address: "{{ hostvars[item].ansible_host }}" | |
loop: "{{ groups[group_name]|default([]) }}" | |
# Empty dictionary {} | |
- name: Loop through the group_hosts servers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file exist as only one custom extension can be run during deployment. | |
# "Multiple VMExtensions per handler not supported for OS type 'Windows'." | |
# Run Ansible WinRM configuration for VM | |
Set-NetConnectionProfile -Name "Network" -NetworkCategory Private | |
$url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1" | |
$file = "$env:temp\ConfigureRemotingForAnsible.ps1" | |
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file) | |
powershell.exe -ExecutionPolicy ByPass -File $file -DisableBasicAuth -EnableCredSSP -SkipNetworkProfileCheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable CredSSP on VM in Azure to make Ansible work better from beginning. | |
Enable-WSManCredSSP -Role Server -Force | |
Set-Item -Path "WSMan:\localhost\Service\Auth\CredSSP" -Value $true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculating amount from user status which allows to exclude invited users '#' | |
New-UdChart -Title "User credential usage" -Type Bar -AutoRefresh -RefreshInterval 7 @Colors -Endpoint { | |
$uri = 'https://graph.microsoft.com/beta/reports/credentialUserRegistrationDetails' | |
$method = 'GET' | |
$content = Invoke-RestMethod -Method $method -Uri $uri -ContentType "application/json" -Headers @{Authorization = "Bearer $token" } -ErrorAction Stop | |
# Counting | |
$isRegistedCount = ($content.value | Where-Object { ($_.userPrincipalName -notlike "*#*") -and ($_.isRegistered -eq 'True') } | Measure-Object).Count | |
$isEnabledCount = ($content.value | Where-Object { ($_.userPrincipalName -notlike "*#*") -and ($_.isEnabled -eq 'True') } | Measure-Object).Count | |
$isCapableCount = ($content.value | Where-Object { ($_.userPrincipalName -notlike "*#*") -and ($_.isCapable -eq 'True') } | Measure-Object).Count | |
$isMfaRegistered = ($content.value | Where-Object { ($_.userPrincipalName -notlike "*#*") -and ($_.isMfa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set UserPrincipalName | |
$UserPrincipalName = 'First.Last@Example.com' | |
$startDate = (Get-Date).AddDays(-30) | |
$endDate = Get-Date | |
# Get Unified Audit Log for UserLoggedIn operation | |
$UnifiedAuditLogLogin = Search-UnifiedAuditLog -StartDate $startDate -EndDate $endDate -UserIds $UserPrincipalName -Operations UserLoggedIn | |
# Sorting out | |
$lastLoginDate = ($UnifiedAuditLogLogin).CreationDate | ForEach-Object { [datetime]$_ } | Select-Object -First 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$UserPrincipalName = 'First.Last@Email.com' | |
# Get all methods available | |
Get-MsolUser -UserPrincipalName $UserPrincipalName | Select-Object -ExpandProperty StrongAuthenticationMethods | |
# Get only default method | |
Get-MsolUser -UserPrincipalName $UserPrincipalName | Select-Object -ExpandProperty StrongAuthenticationMethods | Where-Object IsDefault -eq True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get active network adapter and information | |
Get-NetConnectionProfile -IPv4Connectivity Internet | Get-NetIPConfiguration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Invoking commands on Hyper-V virtual machine | |
$VM = (Get-VM).Name | |
$session = New-PSSession -VMName $VM -Credential $credentials | |
# Invoking with arguments and creating path to virtual machine if not exist | |
Invoke-Command -Session $session -ArgumentList $vagrantPkgFullPath -ScriptBlock { | |
param ( | |
$vagrantPkgFullPath | |
) | |
if (-not(Test-Path $vagrantPkgFullPath)) |
NewerOlder