< Back

New-LongItem

Sun Jan 19, 2020 5:59 pm

NAME New-LongItem



SYNOPSIS

Creates new file,folder,symboliclink or hardlink items.





SYNTAX

New-LongItem [-Path] <String[]> [-ItemType <String>] [-Value <Object>] [-Encoding <String>] [-Force

<SwitchParameter>] [<CommonParameters>]



New-LongItem [-Path <String[]>] [-ItemType <String>] [-Value <Object>] [-Encoding <String>] -Name <String> [-Force

<SwitchParameter>] [<CommonParameters>]





DESCRIPTION

The New-LongItem cmdlet creates new files or folders depending upon the parameters that are used.This cmdlet can

only create filesystem items(file or folder).





PARAMETERS

-Path <String[]>

Specifies the path to the location of the new item. Wildcards are NOT permitted.



Required? true

Position? 0

Default value

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-ItemType [<String>]

Specifies whether you want to create a file or a folder.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Value [<Object>]





Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Encoding [<String>]





Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Force [<SwitchParameter>]

Allows the cmdlet to create an item that writes over an existing read-only item.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Name <String>

Specifies the name of the new item.

You can specify the name of the new item in the Name or Path parameter value, and you can specify the path to

the new item in the Name or Path parameter value.



Required? true

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, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.String[]













OUTPUTS

Alphaleonis.Win32.Filesystem.FileInfo

For more information see:

http://alphafs.alphaleonis.com/doc/2.0/ ... 08A5E5.htm









-------------------------- EXAMPLE 1 --------------------------



PS C:\\>New-Longitem -path c:\\temp -name logfiles -itemtype directory





-------------------------- EXAMPLE 2 --------------------------



PS C:\\>New-LongItem -ItemType File -path 'c:\\temp\\test.txt', 'c:\\temp\\logs\\test.log'



This command uses the New-LongItem cmdlet to create files in two different directories. Because the Path parameter

takes multiple strings, you can use it to create multiple items.

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>New-LongItem -Path C:\\temp\\123\\456\\hello.txt -Verbose



The New-LongItem cmdlet is used to create the directory tree '123'\\'456' which dosent exist and then finally a

text file 'hello.txt' inside the '456' directory.

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>New-LongItem -Path c:\\temp\\test.txt -ItemType File -Force -Value "1st Line","2nd Line" -Encoding UTF8



Create a text file named test.txt and write 2 lines separated by a line break with UTF8 encoding.

-------------------------- EXAMPLE 5 --------------------------



PS C:\\>New-LongItem -Name test -ItemType Directory



a directory named test is created in the current working directory

-------------------------- EXAMPLE 6 --------------------------



PS C:\\>New-LongItem -Name c:\\temp\\test.txt



we use the name parameter instead of path to create a text file named test.

-------------------------- EXAMPLE 7 --------------------------



PS C:\\>New-LongItem -Path C:\\temp\\MySymlink.txt -Value C:\\temp\\test.txt -ItemType SymbolicLink



a symbolic link named mysymlink.txt is created for an existing file named test located at c:\\temp

-------------------------- EXAMPLE 8 --------------------------



PS C:\\>New-LongItem -Name MySymlink -Value C:\\temp -ItemType SymbolicLink -Force



a symboliclink named mysymlink is created for c:\\temp in the current directory.

Note: since the -Force switch is used any existing symlink named mysymlink will be overwritten.

-------------------------- EXAMPLE 9 --------------------------



PS C:\\>New-LongItem -Path C:\\temp\\MyHardlink.txt -Value C:\\temp\\test.txt -ItemType HardLink



a hardlink named myhardlink is created for the existing file at c:\\temp\\test.txt



RELATED LINKS