I hereby claim:
- I am rleap-m on github.
- I am rleap (https://keybase.io/rleap) on keybase.
- I have a public key ASDmUr9Pekse16W1M6EMQOlYz-FGrJsP09ax2CrxYK5ytwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
# Try running this in PowerShell 5 and then in PowerShell 7 - you'll see different behavior | |
# with the .Split() method | |
$PSVersionTable.PSVersion | |
$tab = [char]9 | |
$hasTab = "[$tab]" | |
$hasTabAndSpace = "[$tab ]" | |
$hasTab | |
$hasTabAndSpace | |
$hasTab.Split(' ') |
Get-NetFirewallRule -DisplayName '*docker*' | | |
ForEach-Object { $ports = Get-NetFirewallPortFilter -AssociatedNetFirewallRule $_; | |
Select-Object -InputObject $_ -Property DisplayName,Enabled,Profile,Direction,Action, | |
@{Name='Protocol'; Expression={$ports.Protocol}},@{Name='LocalPort'; Expression={[int64]$ports.LocalPort}} } | | |
Sort-Object -Property LocalPort | Format-Table |
# This is a 'Bind Mount' (as opposed to a Named volume which is managed by Docker) | |
# https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/persistent-storage | |
# Linux - SELinux - make sure your mount point isn't something like /home or /usr | |
docker container run --rm -it -v "$(pwd)"/containerdata:/data:Z rleapm/mke-mgmt:lnx-1.2 | |
# Windows |
# Command line to run a PowerShell encoded command (allows you to avoid escaping special characters) | |
$runPoshEncodedCmd = 'powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand ' | |
# Command to run in the container - loop which outputs the date to a file and STDOUT | |
$command = "& { Write-Host `"The working directory is [`$(`$pwd.Path)]`";" | |
$command += " `$null = New-Item -Path c:\temp\ -ItemType Directory -ErrorAction SilentlyContinue;" | |
$command += " do { Get-Date -Format s | Tee-Object -FilePath C:\Temp\date_output2.txt -Append;" | |
$command += " Write-Host `"Line count: `$((Get-Content -Path C:\Temp\date_output2.txt).Count)`";" | |
$command += " Start-Sleep -Seconds 5} while (`$true) }" |
# Followed this article: https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/ | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$false)] | |
[ValidateSet('Application','HardwareEvents','Security','System','Windows PowerShell')] | |
[string] $LogFileName = 'Application' | |
) | |
$exportFileName = Join-Path -Path $ENV:TEMP -ChildPath ($ENV:COMPUTERNAME + '_' + $logFileName + "_" + "$(Get-Date -f yyyyMMdd).evtx") |
[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain() |
<# | |
.SYNOPSIS | |
Generates a password | |
.PARAMETER Length | |
Number of characters that should be in the password | |
.PARAMETER NonAlphaMinCount | |
The minimum number of non-alphanumeric characters (such as @, #, !, %, &, and so on) in the generated password | |
.NOTES | |
[email protected] | |
#> |
$sleepTimeSec = 10 # Sleep between data collection iteration | |
$durationinMin = 2 # Collect data for this many minutes | |
# Delete the previous file | |
$csvPath = '.\watch-container-status.csv' | |
if (Test-Path -Path $csvPath -PathType Leaf) { | |
Remove-Item -Path $csvPath | |
} |
Write-Host "Exporting the Application Event Log..." | |
Get-EventLog -LogName Application | Sort-Object -Property TimeGenerated -Descending | | |
Export-Csv -NoTypeInformation -Path ".\$($ENV:COMPUTERNAME)_Event-Log-Application.csv" | |
Write-Host "Exporting the System Event Log..." | |
Get-EventLog -LogName System | Sort-Object -Property TimeGenerated -Descending | | |
Export-Csv -NoTypeInformation -Path ".\$($ENV:COMPUTERNAME)_Event-Log-System.csv" | |
Write-Host "Exporting the Host Compute Service Admin Event Log..." | |
Get-WinEvent -LogName Microsoft-Windows-Hyper-V-Compute-Admin | Sort-Object -Property TimeCreated -Descending | |