Skip to content

Latest commit

 

History

History
221 lines (166 loc) · 4.97 KB

Get-PnPFile.md

File metadata and controls

221 lines (166 loc) · 4.97 KB
external help file applicable schema
SharePoint Server 2013, SharePoint Server 2016, SharePoint Online
2.0.0

Get-PnPFile

SYNOPSIS

Downloads a file.

SYNTAX

Return as file object

Get-PnPFile -Url <String>
            [-Web <WebPipeBind>]
            [-Connection <SPOnlineConnection>]

Return as list item

Get-PnPFile -Url <String>
            [-AsListItem [<SwitchParameter>]]
            [-ThrowExceptionIfFileNotFound [<SwitchParameter>]]
            [-Web <WebPipeBind>]
            [-Connection <SPOnlineConnection>]

Return as string

Get-PnPFile -Url <String>
            [-AsString [<SwitchParameter>]]
            [-Web <WebPipeBind>]
            [-Connection <SPOnlineConnection>]

Save to local path

Get-PnPFile -AsFile [<SwitchParameter>]
            -Url <String>
            [-Path <String>]
            [-Filename <String>]
            [-Force [<SwitchParameter>]]
            [-Web <WebPipeBind>]
            [-Connection <SPOnlineConnection>]

EXAMPLES

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

PS:> Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor

Retrieves the file and downloads it to the current folder

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

PS:> Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -Path c:\temp -FileName company.spcolor -AsFile

Retrieves the file and downloads it to c:\temp\company.spcolor

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

PS:> Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -AsString

Retrieves the file and outputs its contents to the console

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

PS:> Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -AsFile

Retrieves the file and returns it as a File object

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

PS:> Get-PnPFile -Url /sites/project/_catalogs/themes/15/company.spcolor -AsListItem

Retrieves the file and returns it as a ListItem object

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

PS:> Get-PnPFile -Url _catalogs/themes/15/company.spcolor -Path c:\temp -FileName company.spcolor -AsFile

Retrieves the file by site relative URL and downloads it to c:\temp\company.spcolor

PARAMETERS

-AsFile

Type: SwitchParameter
Parameter Sets: Save to local path

Required: True
Position: Named
Accept pipeline input: False

-AsListItem

Returns the file as a listitem showing all its properties

Type: SwitchParameter
Parameter Sets: Return as list item

Required: False
Position: Named
Accept pipeline input: False

-AsString

Retrieve the file contents as a string

Type: SwitchParameter
Parameter Sets: Return as string

Required: False
Position: Named
Accept pipeline input: False

-Filename

Name for the local file

Type: String
Parameter Sets: Save to local path

Required: False
Position: Named
Accept pipeline input: False

-Force

Overwrites the file if it exists.

Type: SwitchParameter
Parameter Sets: Save to local path

Required: False
Position: Named
Accept pipeline input: False

-Path

Local path where the file should be saved

Type: String
Parameter Sets: Save to local path

Required: False
Position: Named
Accept pipeline input: False

-ThrowExceptionIfFileNotFound

If provided in combination with -AsListItem, a Sytem.ArgumentException will be thrown if the file specified in the -Url argument does not exist. Otherwise it will return nothing instead.

Type: SwitchParameter
Parameter Sets: Return as list item

Required: False
Position: Named
Accept pipeline input: False

-Url

The URL (server or site relative) to the file

Type: String
Parameter Sets: Return as file object
Aliases: ServerRelativeUrl,SiteRelativeUrl

Required: True
Position: 0
Accept pipeline input: True

-Connection

Optional connection to be used by cmdlet. Retrieve the value for this parameter by eiter specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type: SPOnlineConnection
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

-Web

This parameter allows you to optionally apply the cmdlet action to a subweb within the current web. In most situations this parameter is not required and you can connect to the subweb using Connect-PnPOnline instead. Specify the GUID, server relative url (i.e. /sites/team1) or web instance of the web to apply the command to. Omit this parameter to use the current web.

Type: WebPipeBind
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

OUTPUTS

RELATED LINKS

SharePoint Developer Patterns and Practices