SharePoint 2010における管理、開発、ユーザそれぞれの立場で使用方法を纏めます。情報がさまざまな場所に分かれてしまっているので、まとめる役割にしたいと思います。分かれてると検索もできないですし。また、実際に使用可能なサンプルを多く載せたいと思います。

PowerShell

SharePoint Server 2010ではPowerShellが使えるようになりました。
PowerShellのバージョンはPowerShell 2.0です。
# SharePoint スナップインを追加
# SharePoint Server 2010 管理コンソールから実行する場合はこの処理は不要
$snapInInfo = Get-PSSnapin | ` Where-Object{$_.Name –eq “Microsoft.SharePoint.PowerShell”}
if ($snapInInfo –eq $null) {
   # SharePoint スナップインが追加されていないので追加する
   Add-PSSnapin Microsoft.SharePoint.PowerShell
}
# 開始時刻を表示
$time = Get-Date
Add-Content C:\Backup\Log\FarmBck.log -Value "バックアップ開始: $time "
Backup-SPFarm -BackupMethod Full -Directory c:\Backup\Farm -BackupThread 3
# 終了時刻を表示
$time = Get-Date
Add-Content C:\Backup\Log\FarmBck.log -Value "バックアップ終了: $time "
Add-Content C:\Backup\Log\FarmBck.log -Value "" # 空白行を追加する
$admin = Get-Credential # リストア権限のあるユーザー名とパスワードを取得
Restore-SPFarm -Directory C:\Backup\Farm -RestoreMethod Overwrite -item `
"ファーム\Microsoft SharePoint Foundation Web Application\Contoso社内サイト" `
 -FarmCredentials $admin –RestoreThreads 3 -Force
Restore-SPFarm -Directory C:\Backup\Farm -ShowTree
Param($URL) # URLパラメータを定義
if ($URL -eq $null) # URLパラメータが指定されない場合はログファイルに書き出して処理を終了
{
   Add-Content C:\Backup\Log\SiteBck.log "サイトURLが指定されていません。"
   Return
}

# SharePoint スナップインを追加
$snapInInfo = Get-PSSnapin –Name Microsoft.SharePoint.PowerShell
if ($snapInInfo –eq $null)
{
   # SharePoint スナップインが追加されていないので追加する
   Add-PSSnapin Microsoft.SharePoint.PowerShell
}

# 日付と時刻をバックアップファイルの名前とするために
# 現在の日付と時刻を取得
$date = Get-Date
# PowerShell 書式指定でファイル名を定義
$BackupFileName = "C:\Backup\Site\{0:yyyyMMdd-HHmm}.bck" -f $date

Backup-SPSite -Identity $URL -Path $BackupFileName
※PowerShellファイル等から
PowerShell C:\Scripts\BackupSite.ps1 –url http://sp2010/Sites/Contoso
のように実行

このページへのコメント

Py0SN4 Appreciate you sharing, great article post.Really looking forward to read more. Really Cool.

0
Posted by awesome things! 2014年01月31日(金) 06:01:53 返信

wI2sYp I really liked your blog.Much thanks again. Cool.

0
Posted by awesome things! 2014年01月21日(火) 17:00:25 返信

CqT97V Thanks again for the blog.Much thanks again. Fantastic.

0
Posted by check it out 2013年12月31日(火) 22:13:51 返信

supHr3 Really enjoyed this article post.Really thank you! Keep writing.

0
Posted by seo thing 2013年12月19日(木) 16:34:17 返信

koGiJm <a href="http://skqbikruiumy.com/">skqbikruiumy</a>, [url=http://tjrikccjyiux.com/]tjrikccjyiux[/url], [link=http://njpofqrglndb.com/]njpofqrglndb[/link], http://opuioqseuuko.com/

0
Posted by igbgbiawg 2013年11月21日(木) 03:05:36 返信

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

メニュー

メンバーのみ編集できます