Creates a new item. (New-Item)

   

# NAME
New-Item

# SYNOPSIS
Creates a new item.

# SYNTAX
New-Item [-Path] <string[]> [-Credential <PSCredential>] [-Force] [-ItemType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

New-Item -Name <string> [[-Path] <string[]>] [-Credential <PSCredential>] [-Force] [-ItemType <string>] [-Value <Object>] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]

# DESCRIPTION
The New-Item cmdlet creates a new item and sets its value. The types of items that can be created depend upon the location of the item. For example, in the file system, New-Item is used to create files and folders. In the registry, New-Item creates registry keys and entries.

New-Item can also set the value of the items that it creates. For example, when creating a new file, New-Item can add initial content to the file.

# PARAMETERS
-Credential <PSCredential>
Specifies a user account that has permission to perform this action. The default is the current user.

Type a user name, such as "User01" or "Domain01\User01", or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows PowerShell

Required? false
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Force [<SwitchParameter>]
Allows the cmdlet to create an item that writes over an existing read-only item. Implementation varies from provider to provider. For more information, see about_Providers. Even using the Force parameter, the cmdlet cannot override security restrictions.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ItemType <string>
Specifies the provider-specified type of the new item.

Required? false
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Name <string>
Specifies the name of the new item. You can use this parameter to specify the name of the new item, or include the name in the value of the Path parameter.

Required? true
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Path <string[]>
Specifies the path to the location of the new item. Wildcards are permitted.

You can specify the name of the new item in the Name parameter, or include it in the Path parameter.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Value <Object>
Specifies the value of the new item. You can also pipe a value to New-Item.

Required? false
Position? named
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actually executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
System.Object
You can pipe a value for the new item to the New-Item cmdlet.

# OUTPUTS
System.Object
New-Item returns the item that it creates.

# NOTES

The New-Item cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type "Get-PsProvider". For more information, see about_Providers.

# EXAMPLE 1

C:\PS>new-item -path . -name testfile1.txt -type "file" -value "This is a text string."

# Description
-----------
This command creates a text file named testfile1.txt in the current directory. The dot (.) in the value of the Path parameter indicates the current directory. The quoted text that follows the Value parameter is added to the file as content.

# EXAMPLE 2

C:\PS>new-item -path c:\ -name logfiles -type directory

# Description
-----------
This command creates a directory named Logfiles in the C: drive. The Type parameter specifies that the new item is a directory, not a file or other file system object.

# EXAMPLE 3

C:\PS>new-item -path $profile -type file -force

# Description
-----------
This command creates a Windows PowerShell profile in the path that is specified by the $profile variable.

You can use profiles to customize Windows PowerShell. $Profile is an automatic (built-in) variable that stores the path and file name of the CurrentUser/CurrentHost profile. By default, the profile does not exist, even though Windows PowerShell stores a path and file name for it.

In this command, the $profile variable represents the path to the file. The Type parameter (or InfoType) specifies that the command creates a file. The Force parameter lets you create a file in the profile path, even when the directories in the path do not exist (Windows PowerShell creates them).

After you use this command to create a profile, you can enter aliases, functions, and scripts in the profile to customize your shell.

For more information, see about_Automatic_Variables and about_Profiles.

# EXAMPLE 4

C:\PS>new-item -type directory -path c:\ps-test\scripts

# Description
-----------
This command creates a new Scripts directory in the C:\PS-Test directory.

The name of the new directory item, Scripts, is included in the value of the Path parameter, instead of being specified in the value of the Name parameter. As indicated by the syntax, either command form is valid.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113353
about_Providers
Get-Item
Set-Item
Remove-Item
Clear-Item
Invoke-Item
Rename-Item
Move-Item
Copy-Item

C:\Windows>powershell get-help Set-Item -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole





... Home  
... Impressum
... ColorConsole

... CMD
... Netsh-XP
... Netsh-7
... Netsh-Vista
... Powershell










Download the Windows 10 Starter, Home (Basic Premium), Professional und Ultimate!

... facebook.de
HTTP: ... PS_Windows/en/New-Item.htm
0.14

Change or ad the language for the keyboard layout in Windows 8.1?

 /

Aero?

 /

Wie kann ich im Windows XP Explorer alle Unterordner öffnen?

 /

Daten Sicher Löschen und den PC-herunterfahren, die Erklärung!

 /