Get users membership from a group in another domain in forest

PS C:\> Get-ADGroupMember -Identity “groupe” -server “another.domain.local”

Advertisements

Check if a file exists

 
Scriptin’10
 
Check if a file exist on a list of computers
Ověření, zda existuje soubor na definovaných strojích
 
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
    ("Select * From CIM_Datafile Where Name = ‘C:\\Program Files\\WinPcap\\Uninstall.exe’")
If colFiles.Count > 0 Then
    Wscript.Echo "yes"
Else
    Wscript.Echo "No"
End If
________________________________________________________________________________
 
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Set objOutputFile = fso.OpenTextFile("vystup.txt", 8, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
Set colFiles = objWMIService.ExecQuery _
    ("Select * From CIM_Datafile Where Name = ‘C:\\Program Files\\AVG\\AVG9\\avgrsx.exe’")
If colFiles.Count > 0 Then
    ObjOutputFile.WriteLine "Ano je AVG9 " & "PC: " & strComputer & vbNewLine
Else
    ObjOutputFile.WriteLine "Neni AVG9 " & "PC : " & strComputer & vbNewLine
End If
Loop
 

Migrate from AVG to Sophos

  
 
– Automatic migrate in 1 script (avg2soph.cmd) added as a logoff script
– Automatická migrace z AVG na Sophos jedním jebem 🙂

_______________________________________________________________________________________________________________________
avg2soph.cmd

@Echo off
if exist “C:\program Files\Sophos\Sophos Anti-Virus\SAVAdminservice.exe” GOTO END
SET RUNAVG=\\domain.local\NETLOGON\psexec.exe \\%computername% -accepteula -u user -p %1 \\Server\AVG\Setup\uninstall\AvgSetup.bat
CALL %RUNAVG%
call
SET RUNSOPHOS=\\domain.local\NETLOGON\psexec.exe \\%computername% -accepteula -u user -p %1 \\domain.local\NETLOGON\soph_inst.bat
CALL %RUNSOPHOS%
:END

______________________________________________________________________________________________________
AvgSetup.bat

@ECHO OFF
REM AVG Setup Batch
SET SETUP=”\\Server\AVG\Setup\uninstall\avg_ipw_stf_all_90_730a1834.exe
IF NOT EXIST %SETUP% GOTO NoSetup
REM Start AVG Setup
%SETUP% /SCRIPT_FILE “\\Server\AVG\Setup\uninstall\AvgSetup.ini” /MANDATORYONLY /CFGFILE_PATH “\\Server\AVG\Setup\uninstall\remoteinst.pck” %1 %2 %3 %4 %5 %6 %7 %8 %9
if %ERRORLEVEL% EQU 1 goto AvgErr
goto End
:AvgErr
ECHO Error while installing AVG
goto End
:NoSetup
ECHO Missing installation files
REM Continue batch processing
:End
ECHO setup returned %ERRORLEVEL%
(AvgSetup.bat a AvgSetup.ini a remoteinst.pck se vytvoří pomocí avg konzole viz.)
http://drnek.spaces.live.com/blog/cns!509D00E35B2D7B2C!329.entry
__________________________________________________________________________________
soph_inst.bat
@Echo off
\\server\SophosUpdate\CIDs\S000\SAVSCFXP\setup.exe -mng yes -crt R -user user -pwd password -updp \\Server\SophosUpdate\CIDs\S000\SAVSCFXP\ -s -ni
__________________________________________________________________________________________
 

 

Diasable UAC

 
 
Script
Disable UAC
Zrušení UAC
Scriptin’9
 
‘Někdy ani domain controler a GP nebere, tak pomůže už jenom script:
 
Const HKEY_LOCAL_MACHINE = &H80000002
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
 
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
 
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
strValueName = "EnableLUA"
dwValue = 0
objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue
Loop