Usuário com melhor resposta
Desligar as Workstation via Script ou GPO

Pergunta
-
Boa Tarde pessoal, estou precisando de um Script ou GPO para desligar todas as estações da rede para que o backup seja efetuado sem erro da arquivos aberto, tem como fazer isso e caso aja algum programa aberto ele feche e salve qq docto aberto?!
E aproveitando á deixa, qual a melhor solução para eu poder transferir o arquivo outlook.pst da estações para que seja feito o backup também??!!!
Respostas
-
Ba Arthur
esta dando erro no link tche.
eu tb gostaria desta solução.
obrigado.
Marcelo,
Criei novamente o link. Tenta nesse https://www.dropbox.com/s/00lfjyfl0m13oyu/DesligarEstacoes.zip
Desliga.bat
@echo off d: cd \support\scripts call d:\support\scripts\lst_comp.vbs FOR /F %%a IN (MachineList.txt) DO ( shutdown /f /s /m \\%%a )
lst_comp.vbs
'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' ' Script Name: GetMachineNames.vbs ' ' Date: January 15, 2006 ' ' Purpose: Pulls object information out of AD ' ' Author: Marlon Meiklejohn ' ' ' Revision History ' ---------------- ' ' Option Explicit ' Define Variables Dim fso Dim WshShell Dim oOu Dim oItem Dim fsOutputFile Dim sOutputText Dim sOutputFileName Dim sOUPath Dim sSearch Dim bRunByCScript Dim iPos ' Set up the system variables Set WshShell = wscript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") ' Check if run from wscript or cscript - Used for debugging. sSearch = "cscript" iPos = InStr(Wscript.FullName, sSearch) If iPos > 0 Then bRunByCScript = True Else bRunByCScript = False End If ' Define the output file name sOutputFileName = ".\MachineList.txt" ' Create the output file Call CreateOutputFile() ' Define the OU path sOUPath = "OU=Desligar,OU=Computadores,DC=empresa,DC=com" '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Main Logic ' ' Define the OU object Set oOu = GetObject("LDAP://" & sOUPath & "") ' Filter for only the objects you want. oOu.Filter = Array("Computer") ' Loop through all objects and grab the ' information you're looking for. For Each oItem In oOu ' Strip out the "CN=" at the beginning of the line. sOutputText = Right(oItem.Name, Len(oItem.Name) - 3) ' If script was run by CScript, then echo the information to the user. If bRunByCScript = True Then Wscript.Echo sOutputText End If ' Write to the output file Call WriteOutputFile (sOutputText) Next ' Close the output file. Call CloseOutputFile() ' Notify the user that the script is finished. ' WScript.echo "File created: " & sOutputFileName ' Cleanup and get out. Call Cleanup() Wscript.Quit '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' SubRoutines ' '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Creates the output file. ' Sub CloseOutputFile() fsOutputFile.Close End Sub '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Creates the output file. ' Sub CreateOutputFile() Set fsOutputFile = fso.CreateTextFile(sOutputFileName) End Sub '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Writes to the output file ' Sub WriteOutputFile(sText) fsOutputFile.WriteLine sText End Sub '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Clean up the variables ' Sub Cleanup() On Error Resume Next Set fso = Nothing Set WshShell = Nothing Set oOu = Nothing Set oItem = Nothing Set fsOutputFile = Nothing Set sOutputText = Nothing Set sOutputFileName = Nothing Set sOUPath = Nothing Set sSearch = Nothing Set bRunByCScript = Nothing Set iPos = Nothing End Sub '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' End of Script ' '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- Editado Fábio JrModerator sexta-feira, 15 de fevereiro de 2013 12:55 Código
- Sugerido como Resposta Fábio JrModerator segunda-feira, 18 de fevereiro de 2013 17:47
- Marcado como Resposta Fábio JrModerator quinta-feira, 28 de fevereiro de 2013 21:17
Todas as Respostas
-
Dacio,
Chegou a procurar no fórum, testou alguma coisa?
LEIA ANTES DE PERGUNTAR: Como utilizar este fórum
Fábio de Paula Junior
-
-
-
Tentei está aqui mais não funcionou, como não conheço muito sobre script e GPO posso ter feito algo errado, pq preciso desligar e salvar tudo que estiver aberto na maquina para não perder nenhuma informação!
http://social.technet.microsoft.com/Forums/pt-BR/scriptadminpt/thread/6bf9781b-e261-4700-b56e-dc59ba5f7403
-
Olá Dacio,
Eu tenho esse script. Funciona da seguinte forma:
Tu escolhe uma OU do teu domínio, move as workstations que desejas desligar e cria uma tarefa agendada no servidor que chame um script que coleta os nomes das máquinas e posteriormente manda o comando para desliga-las no horário selecionado. "Ignorando" as mensagens de erro e demais janelas que constantemente podem aparecer nas workstations.
- Tu pode baixar o script nesse link https://www.dropbox.com/s/ydguhpurndtgdcr/Desligar%20estacoes.zip. Vai baixar uma pasta com dois arquivos: um .bat e um .vbs um precisa do outro para funcionar.
- Coloca em algum diretório que tu possa deixar o script no servidor do AD (de preferência) pois a tarefa agendada vai sempre procurar por esse local.
- Altere o arquivo desliga.bat para as suas necessidades de diretórios.
- Ao criar a tarefa agendada aponte para o desliga.bat, escolha um horário para a execução dessa tarefa e prontinho.
- Mas antes não esqueça de criar uma OU que tu arraste os computadores que deseja desligar e se por ventura quiseres criar uma para que arraste computadores que não precisem ser desligados e alterar a linha 56 do lst_comp.vbs com o caminho da OU selecionada para desligar.
Tenha uma boa tarde.
-
-
Ba Arthur
esta dando erro no link tche.
eu tb gostaria desta solução.
obrigado.
Marcelo,
Criei novamente o link. Tenta nesse https://www.dropbox.com/s/00lfjyfl0m13oyu/DesligarEstacoes.zip
Desliga.bat
@echo off d: cd \support\scripts call d:\support\scripts\lst_comp.vbs FOR /F %%a IN (MachineList.txt) DO ( shutdown /f /s /m \\%%a )
lst_comp.vbs
'_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' ' Script Name: GetMachineNames.vbs ' ' Date: January 15, 2006 ' ' Purpose: Pulls object information out of AD ' ' Author: Marlon Meiklejohn ' ' ' Revision History ' ---------------- ' ' Option Explicit ' Define Variables Dim fso Dim WshShell Dim oOu Dim oItem Dim fsOutputFile Dim sOutputText Dim sOutputFileName Dim sOUPath Dim sSearch Dim bRunByCScript Dim iPos ' Set up the system variables Set WshShell = wscript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") ' Check if run from wscript or cscript - Used for debugging. sSearch = "cscript" iPos = InStr(Wscript.FullName, sSearch) If iPos > 0 Then bRunByCScript = True Else bRunByCScript = False End If ' Define the output file name sOutputFileName = ".\MachineList.txt" ' Create the output file Call CreateOutputFile() ' Define the OU path sOUPath = "OU=Desligar,OU=Computadores,DC=empresa,DC=com" '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Main Logic ' ' Define the OU object Set oOu = GetObject("LDAP://" & sOUPath & "") ' Filter for only the objects you want. oOu.Filter = Array("Computer") ' Loop through all objects and grab the ' information you're looking for. For Each oItem In oOu ' Strip out the "CN=" at the beginning of the line. sOutputText = Right(oItem.Name, Len(oItem.Name) - 3) ' If script was run by CScript, then echo the information to the user. If bRunByCScript = True Then Wscript.Echo sOutputText End If ' Write to the output file Call WriteOutputFile (sOutputText) Next ' Close the output file. Call CloseOutputFile() ' Notify the user that the script is finished. ' WScript.echo "File created: " & sOutputFileName ' Cleanup and get out. Call Cleanup() Wscript.Quit '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' SubRoutines ' '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Creates the output file. ' Sub CloseOutputFile() fsOutputFile.Close End Sub '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Creates the output file. ' Sub CreateOutputFile() Set fsOutputFile = fso.CreateTextFile(sOutputFileName) End Sub '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Writes to the output file ' Sub WriteOutputFile(sText) fsOutputFile.WriteLine sText End Sub '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' Clean up the variables ' Sub Cleanup() On Error Resume Next Set fso = Nothing Set WshShell = Nothing Set oOu = Nothing Set oItem = Nothing Set fsOutputFile = Nothing Set sOutputText = Nothing Set sOutputFileName = Nothing Set sOUPath = Nothing Set sSearch = Nothing Set bRunByCScript = Nothing Set iPos = Nothing End Sub '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ' ' End of Script ' '_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- Editado Fábio JrModerator sexta-feira, 15 de fevereiro de 2013 12:55 Código
- Sugerido como Resposta Fábio JrModerator segunda-feira, 18 de fevereiro de 2013 17:47
- Marcado como Resposta Fábio JrModerator quinta-feira, 28 de fevereiro de 2013 21:17
-
-
-
Pessoal,
Preferencialmente coloquem o código no corpo da mensagem ao invés de colocar em Links do tipo dropbox, rapidshare, etc.
Amanhã alguém pode vir procurar pelo código e o link estar expirado.
Fábio de Paula Junior
Valeu Fabio,
Cheguei a pouco tempo no fórum e acabei não me ligando nesse detalhe.
Obrigado por postar meus scripts no corpo do fórum.
Arthur Ramos SCHAEFER
-