arquivo removido
This commit is contained in:
parent
09b7effa8a
commit
11babafaf1
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*.exe
|
*.exe
|
||||||
var.h
|
var.h
|
||||||
|
*.txt
|
|
@ -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."
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user