Updates from: 05/24/2021 03:06:29
Service Microsoft Docs article Related commit history on GitHub Change details
Microsoft.PowerShell.Management New Item (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Management/New-Item.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 04/23/2019 Last updated : 05/23/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-item?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-Item
you can use it to create multiple items.
New-Item -ItemType "file" -Path "c:\ps-test\test.txt", "c:\ps-test\Logs\test.log" ```
-### Example 6: Use the -Force parameter to attempt to recreate folders
+### Example 6: Use wildcards to create files in multiple directories
+
+The `New-Item` cmdlet supports wildcards in the **Path** parameter. The following command creates a
+`temp.txt` file in all of the directories specified by the wildcards in the **Path** parameter.
+
+```powershell
+Get-ChildItem -Path C:\Temp\
+```
+
+```Output
+ Directory: C:\Temp
+
+Mode LastWriteTime Length Name
+---- ------------- ------ ----
+d----- 5/15/2019 6:45 AM 1 One
+d----- 5/15/2019 6:45 AM 1 Two
+d----- 5/15/2019 6:45 AM 1 Three
+```
+
+```powershell
+New-Item -Path C:\Temp\* -Name temp.txt -ItemType File | Select-Object FullName
+```
+
+```Output
+FullName
+--------
+C:\Temp\One\temp.txt
+C:\Temp\Three\temp.txt
+C:\Temp\Two\temp.txt
+```
+
+The `Get-ChildItem` cmdlet shows three directories under the `C:\Temp` directory. Using wildcards
+the `New-Item` cmdlet creates a `temp.txt` file in all of the directories under the current
+directory. The `New-Item` cmdlet outputs the items you created, which is piped to `Select-Object`
+to verify the paths of the newly created files.
+
+### Example 7: Use the -Force parameter to attempt to recreate folders
This example creates a folder with a file inside. Then, attempts to create the same folder using `-Force`. It will not overwrite the folder but simply return the existing folder object with the
Mode LastWriteTime Length Name
-a---- 5/1/2020 8:03 AM 0 TestFile.txt ```
-### Example 7: Use the -Force parameter to overwrite existing files
+### Example 8: Use the -Force parameter to overwrite existing files
This example creates a file with a value and then recreates the file using `-Force`. This overwrites The existing file and it will lose it's content as you can see by the length property
Microsoft.PowerShell.Management New Item (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Management/New-Item.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 06/18/2020 Last updated : 05/23/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-item?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-Item
d----- 5/15/2019 6:45 AM 1 Three
``` ```powershell
-New-Item -Path * -Name temp.txt -ItemType File | Select-Object FullName
+New-Item -Path C:\Temp\* -Name temp.txt -ItemType File | Select-Object FullName
``` ```Output
Microsoft.PowerShell.Management New Item (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Management/New-Item.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 06/18/2020 Last updated : 05/23/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-item?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-Item
d----- 5/15/2019 6:45 AM 1 Three
``` ```powershell
-New-Item -Path * -Name temp.txt -ItemType File | Select-Object FullName
+New-Item -Path C:\Temp\* -Name temp.txt -ItemType File | Select-Object FullName
``` ```Output
available in your session, type `Get-PsProvider`. For more information, see [abo
[Set-Item](Set-Item.md) [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md)-
Microsoft.PowerShell.Management New Item (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Management/New-Item.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 06/18/2020 Last updated : 05/23/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/new-item?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-Item
d----- 5/15/2019 6:45 AM 1 Three
``` ```powershell
-New-Item -Path * -Name temp.txt -ItemType File | Select-Object FullName
+New-Item -Path C:\Temp\* -Name temp.txt -ItemType File | Select-Object FullName
``` ```Output
available in your session, type `Get-PsProvider`. For more information, see [abo
[Set-Item](Set-Item.md) [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md)-