The complete folder structure has been changed or updated
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
@ECHO OFF
|
||||
TITLE DIGITAL DATA - %~n0
|
||||
ECHO -
|
||||
ECHO Windows Command Line Script
|
||||
ECHO CMD Version %CMDEXTVERSION% active!
|
||||
ECHO -
|
||||
ECHO Digital Data
|
||||
ECHO Ludwig-Rinn-Strasse 16
|
||||
ECHO 35452 Heuchelheim
|
||||
ECHO Tel.: 0641 / 202360
|
||||
ECHO E-Mail: info@didalog.de
|
||||
ECHO -
|
||||
ECHO Version Number: 1.0.0.0
|
||||
ECHO Version Date: 03.06.2018
|
||||
|
||||
pushd "%~dp0"
|
||||
setlocal
|
||||
|
||||
REM --------------------------------------------------------------
|
||||
REM ----------------------- set variables ------------------------
|
||||
REM --------------------------------------------------------------
|
||||
|
||||
SET ScriptName=%~n0
|
||||
REM Automatic defined Variable, do not change!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET ScriptPath=%~dp0
|
||||
REM Automatic defined Variable, do not change!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET SearchPath=%cd%\
|
||||
REM Automatic defined Variable, maybe change, if you want to search in designated folder - dont forget the "\" in the end!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET SearchFileFilter="*-Example.cmd,*-Example.vbs,*.ps1,*-Example.exe"
|
||||
REM Set File extension *.exe, *.ps1, *.vbs or *.cmd. Or set whole Filename like test.ps1. Wildcard is also possible: test*.ps1. Also a comma seperated list is possible like *.ps1, *.vbs.
|
||||
REM Write WITHOUT double Quotes(""), for a single value! Write WITH double Quotes(""), for comma seperated values.
|
||||
|
||||
SET Counter=0
|
||||
REM Predefined Variable, do not change!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET PowerShellCMD=powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File
|
||||
REM Predefined Variable, do not change!
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET PowerShellRuntimeScript="%ScriptPath%\%ScriptName%_PowerShellRuntimeScript.ps1"
|
||||
REM Automatic defined Variable, do not change!
|
||||
REM Write WITH double Quotes("")!
|
||||
|
||||
SET PowerShellWaitForExit=True
|
||||
REM Set to "True" if found EXE or Scripts Files should be processed one after another. Otherwise set to "False".
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET RunAsUserName=
|
||||
REM Set an Username, if you want the EXE or Scripts Files run in an other context, like: "Administrator". But maybe: "domain\Administrator".
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
SET RunAsUserPassword=
|
||||
REM Set Password if you defined the RunAsUserName Variable.
|
||||
REM Write WITHOUT double Quotes("")!
|
||||
|
||||
REM --------------------------------------------------------------
|
||||
GOTO mainpart
|
||||
REM --------------------------------------------------------------
|
||||
REM ------------------------- subroutines ------------------------
|
||||
REM --------------------------------------------------------------
|
||||
:CreatePowerShellRuntimeScript
|
||||
REM GENERIC STARTING PART
|
||||
SET Item=%1
|
||||
ECHO -
|
||||
ECHO Creating PowerShellRuntimeScript for: %Item%
|
||||
ECHO #Automatic generated PowerShellRuntimeScript>%PowerShellRuntimeScript%
|
||||
ECHO Clear-Host>%PowerShellRuntimeScript%
|
||||
ECHO $UserName=^"%RunASUserName%^">>%PowerShellRuntimeScript%
|
||||
ECHO $UserPassword=^"%RunAsUserPassword%^">>%PowerShellRuntimeScript%
|
||||
ECHO $Item=(Get-Item %Item%)>>%PowerShellRuntimeScript%
|
||||
ECHO $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($UserName,(ConvertTo-SecureString -String $UserPassword -AsPlainText -Force))>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
REM BLOCK FOR CMD FILES
|
||||
IF NOT x%Item:.cmd=%==x%Item% (
|
||||
ECHO #Runtime File is exclusive build for %SearchFileFilter%>>%PowerShellRuntimeScript%
|
||||
ECHO $Process = New-Object System.Diagnostics.Process>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Filename = ^"cmd.exe^">>%PowerShellRuntimeScript%
|
||||
IF [%RunASUserName%] EQU [] (
|
||||
ECHO #Start Process in current context.>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $True>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #Start Process in RunAs context.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UserName = $Credentials.UserName>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Password = $Credentials.Password>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $False>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.LoadUserProfile = $True>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO $Process.StartInfo.Arguments = "/c ""$($Item.FullName)""">>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardOutput = $False>>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardError = $True>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.Start^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
REM BLOCK FOR PS1 FILES
|
||||
IF NOT x%Item:.ps1=%==x%Item% (
|
||||
ECHO #Runtime File is exclusive build for %SearchFileFilter%>>%PowerShellRuntimeScript%
|
||||
ECHO $Process = New-Object System.Diagnostics.Process>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Filename = ^"powershell.exe^">>%PowerShellRuntimeScript%
|
||||
IF [%RunASUserName%] EQU [] (
|
||||
ECHO #Start Process in current context.>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $True>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #Start Process in RunAs context.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UserName = $Credentials.UserName>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Password = $Credentials.Password>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $False>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.LoadUserProfile = $True>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO $Process.StartInfo.Arguments = "-ExecutionPolicy Bypass -file ""$($Item.FullName)""">>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardOutput = $False>>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardError = $True>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.Start^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
REM BLOCK FOR VBS FILES
|
||||
IF NOT x%Item:.vbs=%==x%Item% (
|
||||
ECHO #Runtime File is exclusive build for %SearchFileFilter%>>%PowerShellRuntimeScript%
|
||||
ECHO $Process = New-Object System.Diagnostics.Process>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Filename = ^"wscript.exe^">>%PowerShellRuntimeScript%
|
||||
IF [%RunASUserName%] EQU [] (
|
||||
ECHO #Start Process in current context.>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $True>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #Start Process in RunAs context.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UserName = $Credentials.UserName>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Password = $Credentials.Password>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $False>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.LoadUserProfile = $True>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO $Process.StartInfo.Arguments = ^"^"^"^"^"^"^"^"^"^"^"^$^(^$Item.FullName^)^"^"^"^"^"^"^"^"^"^"^">>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardOutput = $False>>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardError = $True>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.Start^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
REM BLOCK FOR EXE FILES
|
||||
IF NOT x%Item:.exe=%==x%Item% (
|
||||
ECHO #Runtime File is exclusive build for %SearchFileFilter%>>%PowerShellRuntimeScript%
|
||||
ECHO $Process = New-Object System.Diagnostics.Process>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Filename = ^"^$^(^$Item.FullName^)^">>%PowerShellRuntimeScript%
|
||||
IF [%RunASUserName%] EQU [] (
|
||||
ECHO #Start Process in current context.>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $True>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #Start Process in RunAs context.>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UserName = $Credentials.UserName>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.Password = $Credentials.Password>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.UseShellExecute = $False>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.StartInfo.LoadUserProfile = $True>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO #$Process.StartInfo.RedirectStandardOutput = $False>>%PowerShellRuntimeScript%
|
||||
ECHO #$Process.StartInfo.RedirectStandardError = $True>>%PowerShellRuntimeScript%
|
||||
ECHO $Process.Start^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
REM GENERIC FINISHING PART
|
||||
IF /i %PowerShellWaitForExit% EQU True (
|
||||
ECHO $Process.WaitForExit^(^)>>%PowerShellRuntimeScript%
|
||||
) ELSE (
|
||||
ECHO #$Process.WaitForExit^(^)>>%PowerShellRuntimeScript%
|
||||
)
|
||||
ECHO #[string] $Out = $Process.StandardOutput.ReadToEnd();>>%PowerShellRuntimeScript%
|
||||
ECHO.>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name UserName -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name UserPassword -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name Item -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name Credentials -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO Remove-Variable -Name Process -Force -ErrorAction SilentlyContinue>>%PowerShellRuntimeScript%
|
||||
ECHO.
|
||||
ECHO Starting RuntimeFile: %PowerShellRuntimeScript%
|
||||
%PowerShellCMD% %PowerShellRuntimeScript%
|
||||
DEL %PowerShellRuntimeScript%
|
||||
GOTO :eof
|
||||
REM --------------------------------------------------------------
|
||||
|
||||
REM --------------------------------------------------------------
|
||||
REM ------------------------- main part --------------------------
|
||||
REM --------------------------------------------------------------
|
||||
:mainpart
|
||||
cls
|
||||
ECHO -
|
||||
ECHO Program Startup: %ScriptName% on %computername%,
|
||||
ECHO from Account: %userdomain%\%username%.
|
||||
ECHO On %date% at %time:~0,8% o'clock.
|
||||
|
||||
REM Count Files and show Counter
|
||||
FOR /F "tokens=*" %%f in ('dir /S /b "%SearchPath%\%SearchFileFilter%"') do (set /a Counter+=1)
|
||||
ECHO -
|
||||
ECHO Found %Counter% File(s) with File extension %SearchFileFilter% in Directory:
|
||||
ECHO %SearchPath%
|
||||
|
||||
REM If Counter greater then 0 call subroutine for every found file
|
||||
IF %Counter% GTR 0 (
|
||||
FOR /F "tokens=*" %%f in ('dir /S /b "%SearchPath%\%SearchFileFilter%"') DO (Call :CreatePowerShellRuntimeScript "%%f")
|
||||
GOTO PlanedExit
|
||||
) ELSE (
|
||||
ECHO -
|
||||
ECHO Found no Files. Exiting...
|
||||
GOTO UnplanedExit
|
||||
)
|
||||
REM --------------------------------------------------------------
|
||||
|
||||
REM --------------------------------------------------------------
|
||||
REM ----------------------- finishing part -----------------------
|
||||
REM --------------------------------------------------------------
|
||||
:UnplanedExit
|
||||
endlocal
|
||||
ECHO -
|
||||
ECHO This Window will close in:
|
||||
timeout /T 10
|
||||
rem pause
|
||||
exit
|
||||
|
||||
:PlanedExit
|
||||
endlocal
|
||||
rem pause
|
||||
exit
|
||||
REM --------------------------------------------------------------
|
||||
@@ -0,0 +1,117 @@
|
||||
#PowerShell 3.0 Script
|
||||
#Please use the "_Settings.ini"-File for configurations.
|
||||
|
||||
#Digital Data
|
||||
#Ludwig-Rinn-Strasse 16
|
||||
#35452 Heuchelheim
|
||||
#Tel.: 0641 / 202360
|
||||
#E-Mail: info@didalog.de
|
||||
|
||||
#Version Number: 1.0.0.0
|
||||
#Version Date: 08.08.2019
|
||||
|
||||
#Requires –Version 3.0
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------#
|
||||
############################################ set variables ############################################
|
||||
#-----------------------------------------------------------------------------------------------------#
|
||||
|
||||
[STRING]$ScriptName=(($MyInvocation.MyCommand.Name) -split "\.")[0].ToString()
|
||||
[STRING]$ScriptPath=(Split-Path ($MyInvocation.MyCommand.Path))
|
||||
[STRING]$LogFile="$((Get-ItemProperty -Path 'HKLM:\SOFTWARE\A.I.S. GmbH\windream\3.6\CommonFiles' -Name AppPath).AppPath)\Reporting\WMCmd.log"
|
||||
[STRING]$WMCMDEXE="$((Get-ItemProperty -Path 'HKLM:\SOFTWARE\A.I.S. GmbH\windream\3.6\CommonFiles' -Name AppPath).AppPath)\ResourceKit\WMCmd.exe"
|
||||
[STRING]$WINDOWSDOMAIN=$env:USERDNSDOMAIN
|
||||
|
||||
[ARRAY]$WINDOWSGROUPS=@("IIMUser-Group","IIMAdmin-Group","VHM-Netz-Administration","VHM-Netz-Geschäftsführung","VHM-Netz-Geschäftsprozesse","VHM-Netz-Personal","VHM-Vertrieb-Administration","VHM-Vertrieb-Geschäftsführung","VHM-Vertrieb-Geschäftsprozesse","VHM-Vertrieb-Personal")
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------#
|
||||
############################################# main part ###############################################
|
||||
#-----------------------------------------------------------------------------------------------------#
|
||||
|
||||
#Clear Error Variable
|
||||
$Error.Clear() | Out-Null
|
||||
|
||||
#Clear Console Output
|
||||
Clear-Host
|
||||
|
||||
TRY {
|
||||
|
||||
Write-Output " " | Out-File $LogFile -Append
|
||||
Write-Output "********************************************************************************" | Out-File $LogFile -Append
|
||||
Write-Output "Program Startup: $ScriptName on $env:COMPUTERNAME at $(Get-Date -Format 'dd.MM.yyyy HH:mm:ss.fff')," | Out-File $LogFile -Append
|
||||
Write-Output "from Account $env:USERDOMAIN\$env:USERNAME." | Out-File $LogFile -Append
|
||||
Write-Output "********************************************************************************" | Out-File $LogFile -Append
|
||||
|
||||
Write-Output "Set LogFile path and name: $LogFile" | Out-File $LogFile -Append
|
||||
Write-Output "Set WMCMD path and name: $WMCMDEXE" | Out-File $LogFile -Append
|
||||
Write-Output "Set Windows Domain (in LDAP notation): $WINDOWSDOMAIN" | Out-File $LogFile -Append
|
||||
Write-Output "Set $($WINDOWSGROUPS.count) Groups for the Sync" | Out-File $LogFile -Append
|
||||
|
||||
Write-Output " " | Out-File $LogFile -Append
|
||||
Write-Output "Start windream Sync..." | Out-File $LogFile -Append
|
||||
Write-Output " " | Out-File $LogFile -Append
|
||||
|
||||
IF (Test-Path -Path $WMCMDEXE -PathType any) {
|
||||
|
||||
FOREACH ($WINDOWSGROUP in $WINDOWSGROUPS) {
|
||||
|
||||
TRY {
|
||||
|
||||
$ProcessStartInfo = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$ProcessStartInfo.FileName = $WMCMDEXE
|
||||
$ProcessStartInfo.RedirectStandardError = $true
|
||||
$ProcessStartInfo.RedirectStandardOutput = $true
|
||||
$ProcessStartInfo.UseShellExecute = $false
|
||||
$ProcessStartInfo.Arguments = "-command `"ADJUST GROUP \`"$WINDOWSDOMAIN\$WINDOWSGROUP\`" ASYNC`" -noprompt -logcmd"
|
||||
$Process = New-Object System.Diagnostics.Process
|
||||
$Process.StartInfo = $ProcessStartInfo
|
||||
$Process.Start() | Out-Null
|
||||
$ProcessStandardOutput = $Process.StandardOutput.ReadToEnd()
|
||||
If ($ProcessStandardOutput) { $ProcessStandardOutput | Out-File $LogFile -Append }
|
||||
$ProcessStandardError = $Process.StandardError.ReadToEnd()
|
||||
IF ($ProcessStandardError) { $ProcessStandardError | Out-File $LogFile -Append }
|
||||
$Process.WaitForExit()
|
||||
|
||||
} #end try
|
||||
|
||||
CATCH {
|
||||
|
||||
Write-Output "Error processing Sync!" -PipelineVariable | Out-File $LogFile -Append
|
||||
Write-Output $Error | Out-File $LogFile
|
||||
|
||||
} #end catch
|
||||
|
||||
} #end foreach
|
||||
|
||||
} #end if
|
||||
|
||||
ELSE {
|
||||
|
||||
Write-Output "WMCMD does not exist!" | Out-File $LogFile -Append
|
||||
|
||||
} #end else
|
||||
|
||||
Write-Output " " | Out-File $LogFile -Append
|
||||
Write-Output "********************************************************************************" | Out-File $LogFile -Append
|
||||
Write-Output "Program Completed: $ScriptName on $env:COMPUTERNAME at $(Get-Date -Format 'dd.MM.yyyy HH:mm:ss.fff')," | Out-File $LogFile -Append
|
||||
Write-Output "from Account $env:USERDOMAIN\$env:USERNAME." | Out-File $LogFile -Append
|
||||
Write-Output "********************************************************************************" | Out-File $LogFile -Append
|
||||
|
||||
} #end try
|
||||
|
||||
CATCH {
|
||||
|
||||
Write-Warning "Cannot write LogFile!"
|
||||
|
||||
} #end catch
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------#
|
||||
########################################### finishing part ############################################
|
||||
#-----------------------------------------------------------------------------------------------------#
|
||||
|
||||
Remove-Variable -Name ScriptName -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name ScriptPath -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name LogFile -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name WMCMDEXE -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name WINDOWSDOMAIN -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name WINDOWSGROUPS -Force -ErrorAction SilentlyContinue
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Version 1.0.0.0 - 07.08.2019
|
||||
NEW: -
|
||||
FIX: -
|
||||
CHG: -
|
||||
REM: -
|
||||
|
||||
-------------------------------------legend------------------------------------
|
||||
NEW: = Added a new functionality
|
||||
FIX: = Fixed a Issue with existing functionality
|
||||
CHG: = Changed a existing functionality
|
||||
REM: = Removed a functionality
|
||||
-------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user