LoginSignup
7

More than 5 years have passed since last update.

PowerShell で SharePoint の リストの列

Posted at
Add-PSSnapin Microsoft.SharePoint.PowerShell
$ErrorActionPreference = "Stop"

# リストの列の一覧(表示名、内部名、隠し属性、タイプ表示名)を取得
# 引数は、サイトURL($WebUrl), リスト表示名($ListDisplayName)
function getListFields( $WebUrl, $ListDisplayName ) {
    # サイト取得
    $web  = Get-SPWeb $WebUrl
    Write-Host "Web : $WebUrl"

    # リスト取得
    $list = $web.Lists | ?{ $_.title -eq $ListDisplayName }
    Write-Host "List : $($list.Title)"

    # 列の一覧を出力(表示名、内部名、隠し属性、タイプ表示名)
    $list.Fields | Select Title, InternalName, Hidden, TypeDisplayName
}
# 使用例 -----------------------------------------------------------------
$webUrl          = "http://hoge/my"
$listDisplayName = "ドキュメント"
# 例1)コンソールに出力
getListFields -webUrl $webUrl -listDisplayName $listDisplayName | Format-Table
# 例2)ポップアップビューに出力
getListFields -webUrl $webUrl -listDisplayName $listDisplayName | Out-GridView
# 例3)ファイルに出力
getListFields -webUrl $webUrl -listDisplayName $listDisplayName | Export-Csv -Path "(ファイルパス).csv" -Encoding UTF8 -NoTypeInformation

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
7