arquivo removido

This commit is contained in:
jonatanorue 2024-09-04 12:02:20 -04:00
parent 09b7effa8a
commit 11babafaf1
2 changed files with 1 additions and 37 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
*.exe
var.h
*.txt

View File

@ -1,37 +0,0 @@
# Credenciais
$domain = "acad.pp.ifms.edu.br"
$username = "u1336745"
$password = "sao5numeros"
$searchBase = "DC=acad,DC=pp,DC=ifms,DC=edu,DC=br"
$computerName = "PP-lenovoTest"
# Cria as credenciais
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ($username, $securePassword)
# Conecta ao domínio
$ldapConn = New-Object DirectoryServices.DirectoryEntry ("LDAP://$domain", $username, $password)
# Cria o objeto para pesquisa
$searcher = New-Object DirectoryServices.DirectorySearcher
$searcher.SearchRoot = $ldapConn
$searcher.Filter = "(&(objectCategory=computer)(cn=$computerName))"
# Executa a pesquisa
$result = $searcher.FindOne()
if ($result) {
# Se o computador for encontrado, obtém o caminho do objeto
$computerObject = $result.GetDirectoryEntry()
# Remove o computador
try {
$computerObject.DeleteTree()
$computerObject.CommitChanges()
Write-Host "Computador '$computerName' deletado com sucesso."
} catch {
Write-Host "Erro ao deletar o computador: $_"
}
} else {
Write-Host "Computador '$computerName' não encontrado."
}