$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.'