This file contains 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 credentials | |
$AdminCredentials = Get-Credential "myadmin@oholics.net" | |
# Create the session | |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $AdminCredentials -Authentication Basic -AllowRedirection | |
# Import the session | |
Import-PSSession $Session -DisableNameChecking | |
# Define the tenant | |
$MyTenant = "CN=Configuration,CN=<TenantID>.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=FFO,DC=extest,DC=microsoft,DC=com" | |
# Create the label | |
New-Label -DisplayName "My Label" -Name "My Label" -Comment "This is My Label" -Tooltip "My Label Tooltip" -AdvancedSettings @{color="#32CD32"} |
This file contains 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
Connect-AzureRmAccount | |
$Logfile = "C:\Temp\RoleAssignmentsLog.csv" | |
If (Test-Path $Logfile) { | |
Clear-Content -Path $Logfile | |
} | |
$Subscription1 = "<SubscriptionGUID>" | |
$Subscription2 = "<SubscriptionGUID>" | |
Add-Content $Logfile "RG/Subscription,RoleDefinitionName,DisplayName,SignInName,ObjectType" | |
#Do first subscription top level | |
Set-AzureRmContext -Subscription $Subscription1 |
This file contains 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
Param( | |
$computer, | |
[switch]$clear | |
) | |
Function DeleteOldEventLogs { | |
# Clear old local log files - 7 days kept | |
$LogdateFormat = "dd-MM-yyyy" | |
$Logdate = Get-Date -Format $LogdateFormat | |
$CleanupExec = "C:\BackupScript\DELETEOLD.PS1 -folderpath C:\Event_Logs -fileage 7 -logfile C:\Event_Logs\leanupLog_$Logdate.txt -verboselog" | |
Invoke-Expression $CleanupExec |
This file contains 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
SELECT * INTO C:\TEMP\Output\output.csv | |
FROM C:\TEMP\Logs\* | |
WHERE TimeWritten > TIMESTAMP ( '2009-01-01 01:00:00', 'yyyy-MM-dd hh:mm:ss' ) AND SourceName = 'Microsoft-Windows-Security-Auditing' AND | |
( Strings LIKE '%jon%' OR strings LIKE '%dave%') |
This file contains 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
SELECT * INTO C:\TEMP\Output\output.csv | |
FROM \\DC01.OHOLICS.NET\security;\\DC02.OHOLICS.NET\security;\\DC03.OHOLICS.NET\security | |
WHERE TimeWritten > TIMESTAMP ( '2009-01-01 01:00:00', 'yyyy-MM-dd hh:mm:ss' ) AND SourceName = 'Microsoft-Windows-Security-Auditing' AND | |
( Strings LIKE '%jon%' OR strings LIKE '%dave%') |
This file contains 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
SELECT * INTO C:\TEMP\Output\output.csv | |
FROM \\DC01.OHOLICS.NET\security | |
WHERE TimeWritten > TIMESTAMP ( '2009-01-01 01:00:00', 'yyyy-MM-dd hh:mm:ss' ) AND SourceName = 'Microsoft-Windows-Security-Auditing' AND | |
( Strings LIKE '%jon%' OR strings LIKE '%dave%') |
This file contains 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
SELECT | |
EventLog, | |
RecordNumber, | |
TimeGenerated, | |
TimeWritten, | |
EventID, | |
EventType, | |
EventTypeName, | |
EventCategory, | |
EventCategoryName, |
This file contains 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
Connect-AzureRmAccount | |
$Subscription = "<Subscription-GUID>" | |
$LogFile = "C:\<PATH>\NSGs.csv" | |
If (Test-Path $Logfile) { | |
Clear-Content -Path $Logfile | |
} | |
Add-Content $LogFile "nsg,rule,protocol,SourcePortRange,DestinationPortRange,SourceAddressPrefix,DestinationAddressPrefix,SourceApplicationSecurityGroups,DestinationApplicationSecurityGroups,Access,Priority,Direction" | |
Set-AzureRmContext -Subscription $Subscription | |
$NSGs = Get-AzureRmNetworkSecurityGroup | |
foreach ($nsg in $NSGs) { |
This file contains 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
$TenantId = "<AzureADTenantID>" | |
$ApplicationId = "<AppID>" | |
$Cert=Get-ChildItem cert:\CurrentUser\My\"<CertificateThumbprint>" | |
# Connect to Azure AD: | |
Connect-AzureAD -TenantId $TenantId -ApplicationId $ApplicationId -CertificateThumbprint $Cert.Thumbprint | |
# e.g. Get-AzureADUsers | |
# Connect to AzureRM: | |
Connect-AzureRmAccount -CertificateThumbprint $Cert.Thumbprint -ApplicationId $ApplicationId -Tenant $TenantId -ServicePrincipal | |
# e.g. Get-AzureRMResourceGroup |
This file contains 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
$Subscription = "<Subscription-GUID>" | |
$PathToPFXCertificate = "C:\<PATH>\<CertName>.pfx" | |
$PFXPassword = "<Password>" | |
$CertPassword = ConvertTo-SecureString $PFXPassword -AsPlainText -Force | |
$ApplicationName = "<AppName>" | |
Import-Module AzureRM.Resources | |
Connect-AzureRmAccount | |
Set-AzureRmContext -Subscription $Subscription | |
$PFXCert = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList @($PathToPFXCertificate, $CertPassword) | |
$KeyValue = [System.Convert]::ToBase64String($PFXCert.GetRawCertData()) |