Skip to content

Instantly share code, notes, and snippets.

@enthusedcoder
Created March 20, 2023 06:23
Show Gist options
  • Save enthusedcoder/087b20930bf2741af7b5edc853e97bed to your computer and use it in GitHub Desktop.
Save enthusedcoder/087b20930bf2741af7b5edc853e97bed to your computer and use it in GitHub Desktop.
Updates the drivers
function Use-RunAs
{
# Check if script is running as Adminstrator and if not use RunAs
# Use Check Switch to check if admin
param([Switch]$Check)
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()`
).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
if ($Check) { return $IsAdmin }
if ($MyInvocation.ScriptName -ne "")
{
if (-not $IsAdmin)
{
try
{
$arg = "-file `"$($MyInvocation.ScriptName)`""
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop'
}
catch
{
Write-Warning "Error - Failed to restart script with runas"
break
}
exit # Quit this session of powershell
}
}
else
{
Write-Warning "Error - Script must be saved as a .ps1 file first"
break
}
}
Use-RunAs
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)
$manu = Get-WmiObject -Class CIM_Product -Namespace "root\cimv2"
Try
{
Get-itemproperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "deploy" -ErrorAction Stop
}
Catch
{
gpupdate /force
$wmi1 = Get-WmiObject -Namespace "root\CIMV2" -Class "Win32_ComputerSystem"
If ($wmi1.Domain -like "WORKGROUP")
{
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory private
}
Get-NetFirewallRule -DisplayGroup "File and Printer Sharing", "Network Discovery" | Set-NetFirewallRule -Profile 'Private, Domain' -Enabled true -PassThru | select Name,DisplayName,Enabled,Profile | ft -a
Set-ItemProperty -Path 'hklm:\Software\Microsoft\Windows\CurrentVersion\Run' -name "deploy" -Value '%APPDATA%\go.bat' -type 'ExpandString'
Write-Output "powershell -Executionpolicy bypass -Command `"Start-Process powershell -ArgumentList $PSScriptRoot\driver.ps1`"" | Out-File -filepath "$env:APPDATA\go.bat" -Encoding ascii -Force
$wmi2 = Get-WmiObject -Namespace "root\CIMV2" -Class "Win32_OperatingSystem"
If ($wmi2.Caption -like "Microsoft Windows 10 Pro")
{
[String]$enstring = Get-Content "C:\programdata\encryptpass.txt"
$newsec = ConvertTo-SecureString $enstring -Key $key
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList "william.higgs@usan.com", $newsec
Get-PackageProvider -Name NuGet -ForceBootstrap
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-module packagemanagement -force -allowclobber
Install-module powershellget -force -allowclobber
Install-Module Az -force -allowclobber
$login = Connect-AzAccount -Credential $cred
$oskey = (Get-AzKeyVaultSecret -VaultName myoskeys -Name Windows10).SecretValueText
Start-process "cscript.exe" -ArgumentList "slmgr.vbs /ipk $oskey" -WindowStyle Hidden -Wait
}
Start-Process "cscript.exe" -ArgumentList "slmgr.vbs /skms 192.168.2.2:1688" -WindowStyle Hidden -Wait
Start-Process "cscript.exe" -ArgumentList "slmgr.vbs /ato" -WindowStyle Hidden -Wait
. { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
choco install sysinternals -y
If ($manu.Manufacturer -like "Dell Inc.")
{
Invoke-webrequest https://dl.dell.com/FOLDER06095745M/1/Dell-Command-Update_Y2PJJ_WIN_3.1.1_A00.EXE -outfile "$env:USERPROFILE\Desktop\dell.exe"
Start-process "$env:USERPROFILE\Desktop\dell.exe" -Argumentlist "/s" -wait
Do
{
Start-Sleep 5
}
Until ((Get-process).Name -notcontains "dell")
}
}
If ($manu.Manufacturer -like "Dell Inc.")
{
. "$env:ProgramFiles\Dell\CommandUpdate\dcu-cli.exe" /applyUpdates -reboot=enable -updateSeverity="recommended,optional,critical" -updateType="bios,firmware,driver,application,others"
}
Else
{
If (!(Test-Path "$env:USERPROFILE\Desktop\SDI_RUS\SDI_auto.bat"))
{
$parts = Get-Partition | Where-Object {$_.DriveLetter -match "[A-Za-z]{1}"}
$thelet = ""
Foreach ($item in $parts)
{
If (Test-Path "$($item.DriveLetter):\SDI_RUS\SDI_auto.bat")
{
Copy-Item "$($item.DriveLetter):\SDI_RUS" "$env:USERPROFILE\Desktop\" -Recurse -Force
}
}
}
. "$env:USERPROFILE\Desktop\SDI_RUS\SDI_auto.bat" -autoinstall -autoclose -showconsole -verbose:4095 -finishrb_cmd:"shutdown /r /f /t 0"
Do
{
Start-Sleep 5
}
Until ((Get-Process).NAme -notcontains "SDI_x64_R2000")
}
Start-Sleep 30
(Invoke-WebRequest "https://gitlab.com/snippets/1963454/raw").Content | Out-File "$env:USERPROFILE\Desktop\beg.ps1" -Encoding ascii -Force
Remove-Item "$env:APPDATA\go.bat" -Force
Write-Output "powershell -Executionpolicy bypass -Command `"Start-Process powershell -ArgumentList $env:USERPROFILE\Desktop\beg.ps1`"" | Out-File -filepath "$env:APPDATA\go.bat" -Encoding ascii -Force
Restart-Computer -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment