Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- PowerShell objPowershell = PowerShell.Create();
- objPowershell.Commands.Clear();
- objPowershell.Commands.AddScript(" test-connection -count 1 " + TxtIp.Text);
- //On ajoute la première ligne de script
- Collection<PSObject> colResults = objPowershell.Invoke();
- if (colResults.Count>=1)
- {
- testdeconnec.Text = "Réussi";
- }
- //On exécute les 3 lignes de script qui ajoute un utilisateur dans AD
- objPowershell.Commands.Clear();
- objPowershell.Commands.AddScript("$Error");
- Collection<PSObject> colmarchepas = objPowershell.Invoke();
- if (colmarchepas.Count>0)
- {
- testdeconnec.Text = "Échouer";
- }
- //ON LIBÈRE LA MÉMOIRE POUR L'OBJET POWERSHELL
- objPowershell.Dispose();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement