Update
This commit is contained in:
@@ -9,13 +9,16 @@ $script:checks=0
|
||||
function Assert { param($Condition,$Message) if(-not $Condition){throw $Message}; $script:checks++ }
|
||||
function Invoke-Command { param($ComputerName,$ScriptBlock,[object[]]$ArgumentList,$ErrorAction) & $ScriptBlock @ArgumentList }
|
||||
function Test-Path { $true }
|
||||
$priorSystemDrive=$env:SystemDrive
|
||||
$env:SystemDrive='E:'
|
||||
function New-CimSessionOption { param($Protocol,$ErrorAction) if($Protocol -ne 'Dcom'){throw 'Falsches Protokoll'}; 'DCOM' }
|
||||
function New-CimSession { param($ComputerName,$SessionOption,$ErrorAction) $ComputerName }
|
||||
function Get-CimInstance { [pscustomobject]@{SystemDrive='E:'} }
|
||||
function Remove-CimSession { }
|
||||
$script:ServerDestinationPaths=@{}
|
||||
$script:DestinationPath=''
|
||||
Assert ((Resolve-WindowsFolder 'server01') -eq 'E:\ndtrack') 'Systemlaufwerk E nicht verwendet'
|
||||
$env:SystemDrive='D:'
|
||||
Assert ((Resolve-WindowsFolder 'server02') -eq 'D:\ndtrack') 'Systemlaufwerk nicht pro Server aufgeloest'
|
||||
$env:SystemDrive=$priorSystemDrive
|
||||
Assert ((Resolve-WindowsFolder 'server01') -eq 'E:\ndtrack') 'Automatisches Systemlaufwerk falsch'
|
||||
$script:ServerDestinationPaths=@{'server02'='E:\ndtrack'}
|
||||
Assert ((Get-WindowsSharePath 'server02') -eq '\\server02\E$\ndtrack') 'Server-Ausnahme falsch'
|
||||
$script:ServerDestinationPaths=@{}
|
||||
$script:DestinationPath='D:\Tools\ndtrack'
|
||||
Assert ((Resolve-WindowsFolder 'server01') -eq 'D:\Tools\ndtrack') 'Dynamischer Zielpfad falsch'
|
||||
$rejected=$false
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
$ErrorActionPreference='Stop'
|
||||
. (Join-Path (Split-Path $PSScriptRoot -Parent) 'NDTrack-Geprueft.ps1') -LibraryOnly
|
||||
$script:DestinationPath=''; $script:ServerDestinationPaths=@{}
|
||||
$script:removed=0; $script:wmiFail=$false
|
||||
function New-CimSessionOption { param($Protocol,$ErrorAction) if($Protocol -ne 'Dcom'){throw 'WinRM statt DCOM verwendet'}; 'DCOM' }
|
||||
function New-CimSession { param($ComputerName,$SessionOption,$ErrorAction) $ComputerName }
|
||||
function Get-CimInstance { param($CimSession,$ClassName,$Property,$ErrorAction)
|
||||
if($script:wmiFail){throw 'WMI nicht erreichbar'}
|
||||
if($CimSession -eq 'sql01.example'){[pscustomobject]@{SystemDrive='D:'}}else{[pscustomobject]@{SystemDrive='C:'}}
|
||||
}
|
||||
function Remove-CimSession { $script:removed++ }
|
||||
|
||||
$script:SourcePath='source'; $script:WindowsLauncher='Run.cmd'
|
||||
$script:copied=@(); $script:shareAvailable=$true
|
||||
function Test-SourceFiles { }
|
||||
function Invoke-Command { throw 'WinRM darf beim Kopieren nicht verwendet werden' }
|
||||
function New-PSSession { throw 'Keine WinRM-Sitzung erlaubt' }
|
||||
function Test-Path { param($LiteralPath,$PathType,$ErrorAction) if($LiteralPath -like '*.ndtrack-running'){return $false}; $script:shareAvailable }
|
||||
function New-Item { }
|
||||
function Get-ChildItem { [pscustomobject]@{Name='Run.cmd'} }
|
||||
function Copy-Item { param([Parameter(ValueFromPipeline)]$InputObject,$Destination,[switch]$Recurse,[switch]$Force) process {$script:copied += $Destination} }
|
||||
$result=@(CopyFile @('win01.example','sql01.example'))
|
||||
if(($result -join ',') -ne 'win01.example,sql01.example'){throw 'Falsche Erfolgsrueckgabe'}
|
||||
if(($script:copied -join ',') -ne '\\win01.example\C$\ndtrack,\\sql01.example\D$\ndtrack'){throw 'Falsche SMB-Ziele'}
|
||||
$script:shareAvailable=$false; $script:copied=@()
|
||||
$result=@(CopyFile @('win01.example'))
|
||||
if($result.Count -or $script:copied.Count){throw 'Kopiert trotz fehlender Freigabe'}
|
||||
Write-Host 'SMB-Kopieren: Standard C$, Ausnahme D$, Fehlerfall und keine WinRM-Aufrufe geprueft.'
|
||||
|
||||
$script:shareAvailable=$true; $script:wmiFail=$true; $script:copied=@()
|
||||
$result=@(CopyFile @('sql01.example'))
|
||||
if($result.Count -or $script:copied.Count){throw 'Kopiert trotz WMI-Fehler'}
|
||||
if($script:removed -ne 4){throw 'CIM-Sitzungen nicht bereinigt'}
|
||||
Write-Host 'Dynamische Laufwerke C:/D:, WMI-Fehler und Sitzungsbereinigung bestanden.'
|
||||
Reference in New Issue
Block a user