我有一个具有以下文件夹结构的目录:
- BookingService
- DEV
- BookingService.config
- UAT
- BookingService.config
- LIVE
- BookingService.config
- DriverService
- DEV
- DriverService.config
- UAT
- DriverService.config
- LIVE
- DriverService.config
- 的AccountService
- DEV
- AccountService.config
- UAT
- AccountService.config
- LIVE
- AccountService.config
我想遍历每个文件夹和底层DEV,UAT,LIVE子文件夹以提取* .config文件的内容。
到目前为止,我已尝试过以下操作,但不断收到错误消息:Cannot process argument because the value of argument "path" is null
。我该如何解决?
$branch = "C:\work\Services"
$targetEnv = "DEV"
Get-ChildItem -Path $branch | % {
cd $_.DirectoryName
. $_.FullName
($path = Resolve-Path "$($_.DirectoryName\($targetEnv)*\*.config") 2> $null
if ($path -ne $null)
{
# do some stuff here
}
}