Skip to content

Instantly share code, notes, and snippets.

@rafaelfoster
Last active September 12, 2020 10:29
Show Gist options
  • Save rafaelfoster/85061ae2b74fe1dde41e1b33a3ea8d93 to your computer and use it in GitHub Desktop.
Save rafaelfoster/85061ae2b74fe1dde41e1b33a3ea8d93 to your computer and use it in GitHub Desktop.
A Powershell script to update SophosBRLabs in order to have Windows machines working for Bootcamp labs
slmgr /rearm
$UserEmail = Read-Host -Prompt 'Digite o seu email do domínio @sophosbrlabs.com.br (digitar email completo)'
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 )
$Password = "SophosBootcamp#2020"
$UserName = $UserEmail.Split("@")
$ComputerName = $UserName[0].toUpper()
$ComputerName = "WS-" + $ComputerName -replace '[.]'
$ComputerName = $ComputerName + "-" + $randString
$ComputerName = $ComputerName.toUpper()
echo $ComputerName
Write-Host "Criando seu usuário como administrador"
Start-Sleep -Seconds 2
NET USER $Username $Password /add /y /expires:never
NET LOCALGROUP "Administrators" $Username /add
Write-Host "Depois que o computador for iniciado, utilize o seu usuário para fazer o login conforme abaixo:"
Write-Host $UserEmail
Start-Sleep -Seconds 5
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"
Rename-Computer $ComputerName -Force
Write-Host "Reiniciando o computador"
shutdown -r -f -t 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment