Last active
September 13, 2020 12:17
-
-
Save rafaelfoster/ca1e09f5149ccce46389e5638575b509 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 | |
Write-Host "Habilitando o serviço MCS para podermos resetar este device." | |
Start-Sleep -Seconds 2 | |
Set-Service -Name "Sophos MCS Client" -StartupType Automatic | |
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