This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 読み込むCSVのパスをセット | |
$csvPath = "C:\ADユーザー編集ツール\新規ユーザー作成\Source.csv" | |
# CSVファイルをUTF-8にエンコード(UTF-8にしないと日本語が文字化けする) | |
(Get-Content -Path $csvPath -Encoding default) | Set-content -Path $csvPath -Encoding UTF8 | |
# CSVファイルからデータを取り込み | |
$users = Import-Csv -Path $csvPath | |
# ADにユーザーを作成する |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###特定のフォルダ配下の全ファイルのファイルパスと容量をCSV出力する | |
$files = Get-ChildItem -Path "C:\example" -File -Recurse | | |
###ファイルサイズをそれぞれKB単位とMB単位で計算し、MB単位の項目で降順にする(ファイルサイズ多い順に出力する) | |
Select-Object FullName,@{Name="SizeKB"; Expression={[math]::Round($_.Length / 1KB,2)}},@{Name="SizeMB"; Expression={[math]::Round($_.Length / 1MB,2)}} | | |
Sort-Object -Property SizeMB -Descending | |
$files | Export-Csv -PAth "C:\result.csv" -Encoding UTF8 -NoTypeInformation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$tmpCred = Get-Credential | |
$tmpCred.Password | ConvertFrom-SecureString | Set-Content "C:\xxx\pwd.dat" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#予め作成した認証情報を取り込み | |
$password = Get-Content "pwd.dat" | ConvertTo-SecureString | |
#認証情報を変数に取り込んで認証 | |
$credential = New-Object System.Management.Automation.PsCredential "xxx@xxx.co.jp", $password | |
$msolcred=$credential | |
#O365に接続 | |
connect-msolservice -credential $msolcred |