# /dev/null analogue in Powershell 7

**URL:** <https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003>\
**Category:** PowerShell Help\
**Created:** [November 20, 2021, 2:07pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003 "2021-11-20T14:07:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tibor](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tibor](https://forums.powershell.org/u/tibor)\
**Post date:** [November 20, 2021, 2:07pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003/1 "2021-11-20T14:07:16Z")

</div>

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:  
jack@JACK-HP:/mnt/c/Users/baton$

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!

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 20, 2021, 3:10pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003/2 "2021-11-20T15:10:33Z")

</div>

tibor,  
Welcome to the forum. 👋🏽

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:

```auto
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](https://en.wikipedia.org/wiki/Everything_is_a_file)”

---

<div class="post-metadata">

**Author:** ![tibor](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tibor](https://forums.powershell.org/u/tibor)\
**Post date:** [November 20, 2021, 3:57pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003/3 "2021-11-20T15:57:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 20, 2021, 4:07pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003/4 "2021-11-20T16:07:36Z")

</div>

> [@tibor](#):
>
> I would like to know whether there is a 100% analogue for /dev/null or not.

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

> [@tibor](#):
>
> 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.

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.

> [@tibor](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![tibor](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tibor](https://forums.powershell.org/u/tibor)\
**Post date:** [November 20, 2021, 5:31pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003/5 "2021-11-20T17:31:08Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 20, 2021, 6:10pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003/6 "2021-11-20T18:10:40Z")

</div>

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

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

```

> [@tibor](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![tibor](https://avatars.discourse-cdn.com/v4/letter/t/898d66/32.png) [@tibor](https://forums.powershell.org/u/tibor)\
**Post date:** [November 20, 2021, 8:21pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003/7 "2021-11-20T20:21:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:20pm UTC](https://forums.powershell.org/t/dev-null-analogue-in-powershell-7/18003/8 "2024-05-16T20:20:12Z")

</div>

Closed on May 16, 2024, 8:20pm UTC


