Get-childitem: Can not get the subfolders from another subfolders to out-gridview: Error Cannot find path because it does not exist

Could anyone please assist me on this issue? I have been trying to resolve this issue from last one week but I am not able to resolve this and need your help.

What is the goal of this script?

  1. Need to delete big SQL dump files remotely.
  2. When script is launched, we need to click on ok while parent folder is selected/highlighted.
  3. After then we need click on ok so that we can go to its subfolder.
  4. Finally we need to select the files and hit OK. It will delete the selected files.
  5. For this, a GUI PS script needs to be created.
  6. Files to be deleted are under subfolder of another subfolder.

Error while executing this script:

**`Get-ChildItem : Cannot find path ‘C:UsersUjjwal Mandal@{name=All Documents; Size=6.18 GB}’ because it does not exist.
At D:projecttest.ps1:30 char:20

  • $child1= $output | Get-ChildItem | Out-GridView -Title “Select server …`
    **

My PowerShell code for this

Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$TempFile = [io.path]::GetTempFileName()
$form = New-Object System.Windows.Forms.Form
$form.Text = "Fix low space issue"
$form.size =  New-Object System.Drawing.Size(900,400)
$remdmp = New-Object System.Windows.Forms.Button
$remdmp.Location = New-Object System.Drawing.Size(300,35)
$remdmp.Size = New-Object System.Drawing.Size(300,45)
$remdmp.Text = "Remove dump Files"
$remdmp.Font = [System.Drawing.Font]::new('Microsoft Sans Serif', 10, [System.Drawing.FontStyle]::Bold)
$remdmp.Add_Click({
Remove-Item $TempFile -ErrorAction SilentlyContinue
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$svrs ="TM-ND0276"
$path = "\TM-ND0276d$"
$size = 0
$decimalPlaces = 2
$output = @()
$data=Get-ChildItem -Directory $path | ForEach-Object {
 $size += (Get-ChildItem -Recurse $_.FullName | Measure-Object -Property Length -Sum).Sum
 $output += New-Object PSObject -Property @{
 name = $_.Name
 Size = "{0:N$decimalPlaces} GB" -f ((Get-ChildItem -Recurse $_.FullName | Measure-Object -Property Length -Sum).Sum / 1GB)
 }
}

$output | Sort-Object -Descending -Property Size | Out-GridView -Title "select" -PassThru 
$child1= $output | Get-ChildItem | Out-GridView -Title "Select server name folder you want to delete the dump files from" -PassThru
$child2= $child1 | Get-ChildItem | Out-GridView -Title "Select files you want to delete" -PassThru
if($child2) {
$child2 | Remove-Item -Recurse -Force
$msgbox=[System.Windows.MessageBox]::Show('Dump files have been deleted. Check notepad for available free space in D drive')
$dskspce=Invoke-Command -ComputerName $svrs -ScriptBlock {Get-WmiObject -Class win32_logicaldisk | Format-Table DeviceId, MediaType, @{n="Size";e={[math]::Round($_.Size/1GB,2)}},@{n="FreeSpace";e={[math]::Round($_.FreeSpace/1GB,2)}} }

$dskspce | Format-Table > $TempFile | Notepad $TempFile
}
else{
$msgbox=[System.Windows.MessageBox]::Show('Action has been cancelled. Script will stop here!')
}
})
$Form.Controls.Add($remdmp)

$QUIT = New-Object 'System.Windows.Forms.Button'
$QUIT.DialogResult = 'OK'
$QUIT.Location = '300, 200'
$QUIT.Margin = '5, 5, 5, 5'
$QUIT.Name = 'buttonOK'
$QUIT.Size = '300, 50'
$QUIT.BackColor ="LightGray"
$QUIT.ForeColor ="black"
$QUIT.Text = '&CLOSE'
$QUIT.Font = [System.Drawing.Font]::new('Microsoft Sans Serif', 10, [System.Drawing.FontStyle]::Bold)
$QUIT.UseCompatibleTextRendering = $True
$QUIT.UseVisualStyleBackColor = $False
$QUIT.Add_Click({$form.Add_FormClosing({$_.Cancel=$false});$form.Close()})    
$QUIT.Show()#$QUIT.Hide()
$form.Controls.Add($QUIT)
$form.showdialog()

It looks like object TypeName of output should be “System.IO.DirectoryInfo” however, it is “System.Management.Automation.PSCustomObject” that’s why I am getting this error?

Could anyone please take a look and assist me here? Kindly let me know if you any question.

I have tried all the articles I found on the internet also gone through a PowerShell book but didn’t find much information regarding this error and resolution.

When I click on OK button(after selecting any subfolder folder) it should take me to another subfolder but unfortunately it is not.

Screenshot of this gui and issue:
GUI Script view and sufolders
Error when I click on ok after select a folder

New contributor

Ujjawal Mandal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật