/dev/null analogue in Powershell 7

I would like to find and analogue directory in Powershell.
In Linux I can use /dev/null as a directory, and anything moving there or copying there disappears:

jack@JACK-HP:/mnt/c/Users/jack$ sudo mv /mnt/f/Proba/XXX.txt /dev/null
[sudo] password for jack:

But in Powershell with $null is not possible to do the same:

PS C:\Users\jack> move-item F:\Proba\XXX.txt $null
Move-Item: Cannot process argument because the value of argument “destination” is null. Change the value of argument “destination” to a non-null value.

The examples are only for showing the problem, the real goal is to use this moving in more complicated cases.

Thank you for any comment in this case!

Welcome to the forum. :wave:t4:

If you want to remove something you can use the cmdlets with the verb “remove”. This is how you get a list of all of them:

Get-Command -Verb remove

And no - there is no way to do it just like in linux. In PowerShell there is no “Everything is a file

Thank you, but as I noted, it was a symplified example to show the difference. With the Remove-Item the file is disappearing. When I copy a folder from a distant NAS, a lot of details can not be seen about the directory, and in the process of copying it with robocopy, after copying it can be an unsuitable for me because of the size, or some other case. In the process of copying or moving to /dev/null, I can receive all details of the folder, and decide download it or not. In Linux this directory is /dev/null, in windows command line it is C:\dummy. So I use this time for this purpose in windows C:\dummy, in Linux /dev/null. The problem is solved of course, it can be done in Windows command line and in Linux, too. It was only interesting me to find an analogue in Powershell. The $null is good for redirecting any output, but it can not function as a destination directory, so it is not an analogue.
So my goal with this question not to solve a problem, Powershell is very elastic and it is possible to find other ways to solve any real problems. I would like to know whether there is a 100% analogue for /dev/null or not.

Well … I’d say no - of course not. :wink:

I did not get that part. If you want to get information about an object you can use a get cmdlet. Like Get-ChildItem or Get-Item in case of file system objects.

Really? I’ve never seen such a directory on my Windows machines. :wink:

I also do not have C:\dummy as it is not a real directory. But still I can “copy” there more than 1 TB data while my C drive is in only 500 GB.
See the ps1 script below:
$M = Read-Host “Enter the name of the folder to measure”
robocopy $M c:\dummy /l /xj /e /nfl /ndl /njh /r:0 /mt:64

and an example output from a synology nas folder:
Total Copied Skipped Mismatch FAILED Extras
Dirs : 263 263 0 0 0 0
Files : 3268 3268 0 0 0 0
Bytes : 1.039 t 1.039 t 0 0 0 0
Times : 0:00:00 0:00:00 0:00:00 0:00:00
Ended : Saturday, November 20, 2021 6:13:12 PM

So I have a lot of information about a distant folder, while my “C” drive is only 0.5 TB
It is not a 100% analogue to /dev/null but a good solution for people who are new to Powershell but use CMD for a lot of years. For a time it is easier while studying Powershell and find solution on a “real Powershell way”.

Using the “list mode” of robocopy (option /L) you can provide ANY non existent folder as the destination. For example …

robocopy $M c:\nonsense /l /xj /e /nfl /ndl /njh /r:0 /mt:64

But that’s not a function of the operation system it’s built into robocopy. :wink: If you try this with xcopy or Copy-Item it will not work this way. :wink:

1 Like

Thank you for the clarification. Now I have a bit more understanding how things work.