Created
February 4, 2021 13:34
-
-
Save rafaelfoster/85e8a2bbeec39905a3d7c925bda70ec2 to your computer and use it in GitHub Desktop.
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
slmgr /rearm | |
Function Get-RandomAlphanumericString { | |
[CmdletBinding()] | |
Param ( | |
[int] $length = 8 | |
) | |
Begin{ | |
} | |
Process{ | |
Write-Output ( -join ((0x30..0x39) + ( 0x41..0x5A) + ( 0x61..0x7A) | Get-Random -Count $length | % {[char]$_}) ) | |
} | |
} | |
$randString = (Get-RandomAlphanumericString -length 4 | Tee-Object -variable teeTime ) | |
$UserEmail = Read-Host -Prompt 'Digite o seu email do domínio @sophosbrlabs.com.br (digitar email completo)' | |
$UserName = $UserEmail.Split("@") | |
$ComputerName = $UserName[0] | |
$ComputerName = "WS-" + $ComputerName -replace '[.]' | |
$ComputerName = $ComputerName + "-BTH-" + $randString | |
echo $ComputerName | |
mkdir "C:\resources\" | |
$SophosSetupURL = 'https://api-cloudstation-us-east-2.prod.hydra.sophos.com/api/download/3efe4bda83da0472eef45407d3516874/SophosSetup.exe' | |
$outputSophos = 'C:\resources\SophosSetup.exe' | |
$wc = New-Object System.Net.WebClient | |
$wc.DownloadFile($SophosSetupURL, $outputSophos) | |
'New-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce' -Name SophosSetup -Value 'C:\resources\SophosSetup.exe --quiet' -PropertyType ExpandString | |
C:\resources\SophosSetup.exe --computernameoverride $ComputerName |Out-Null | |
Write-Host "Renomeando o computador para que ele não fique duplicado no Sophos Central" | |
netdom renamecomputer $(Get-WmiObject Win32_Computersystem).name /Newname $ComputerName | |
Write-Host "Reiniciando o computador" | |
Start-Sleep -Seconds 3 | |
shutdown -r -f -t 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment