@@ -154,7 +154,7 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
154
154
}
155
155
156
156
It " Verify Move-Item will not move to an existing file" {
157
- { Move-Item - Path $testDir - Destination $testFile - ErrorAction Stop } | Should - Throw - ErrorId " MoveDirectoryItemIOError ,Microsoft.PowerShell.Commands.MoveItemCommand"
157
+ { Move-Item - Path $testDir - Destination $testFile - ErrorAction Stop } | Should - Throw - ErrorId ' DirectoryExist ,Microsoft.PowerShell.Commands.MoveItemCommand'
158
158
$error [0 ].Exception | Should - BeOfType System.IO.IOException
159
159
$testDir | Should - Exist
160
160
}
@@ -1500,3 +1500,32 @@ Describe "Verify sub-directory creation under root" -Tag 'CI','RequireSudoOnUnix
1500
1500
$dirPath | Should - Exist
1501
1501
}
1502
1502
}
1503
+
1504
+ Describe " Windows admin tests" - Tag ' RequireAdminOnWindows' {
1505
+ It " Verify Move-Item for directory across drives on Windows" - Skip:(! $IsWindows ) {
1506
+ try {
1507
+ # find first available drive letter, unfortunately need to use both function: and Win32_LogicalDisk to cover
1508
+ # both subst drives and bitlocker drives
1509
+ $drive = Get-ChildItem function:[h - z ]: - Name | Where-Object { ! (Test-Path - Path $_ ) -and ! (Get-CimInstance Win32_LogicalDisk - Filter " DeviceID='$_ '" ) } | Select-Object - First 1
1510
+ if ($null -eq $drive ) {
1511
+ throw " Test cannot continue as no drive letter available"
1512
+ }
1513
+
1514
+ $dest = (Resolve-Path - Path $TestDrive ).ProviderPath
1515
+ $null = New-Item - ItemType Directory - Path $dest - Name test
1516
+ $out = subst $drive $dest 2>&1
1517
+ if ($LASTEXITCODE -ne 0 ) {
1518
+ throw " subst failed with exit code ${LASTEXITCODE} for drive '$drive ': $out "
1519
+ }
1520
+
1521
+ $testdir = New-Item - ItemType Directory - Path $drive - Name testmovedir - Force
1522
+ 1 > $testdir \test.txt
1523
+ Move-Item $drive \testmovedir $dest \test
1524
+ " $drive \testmovedir" | Should -Not - Exist
1525
+ " $dest \test\testmovedir\test.txt" | Should - FileContentMatchExactly 1
1526
+ }
1527
+ finally {
1528
+ subst $drive / d
1529
+ }
1530
+ }
1531
+ }
0 commit comments