< Back

Test-GCFileWrite

Mon Jan 13, 2020 8:07 pm

NAME Test-GCFileWrite



SYNOPSIS

Test for both file existance and write permissions.





SYNTAX

Test-GCFileWrite [-Path] <String[]> [<CommonParameters>]





DESCRIPTION

Tries to open the specified file with 'Write' access.

Returns True if writing to the file will be successful.

Returns False if the file does not exist or the user does

not have write access to the file.



Note: This Test cmdlet does not write to the file being tested.



For a detailed report in the console use -Verbose.



Type 'Get-Help Test-GCFileWrite -Online' for extra information.





PARAMETERS

-Path <String[]>

The path to the file under test.



If an array of files is passed into the Path parameter, each

file will be tested. A successful result will only occur if every

file exists and the user has write access to every file.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

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



OUTPUTS

System.Boolean





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



PS C:\\>This example returns True if the specified file exists



and is writable:



Test-GCFileWrite -Path 'D:\\FileUnderTest.txt'









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



PS C:\\>This example returns True if the files in the current path



exists and they are writable:



Get-ChildItem | Select -ExpandProperty FullName | Test-GCFileWrite











RELATED LINKS