Skip to content

Instantly share code, notes, and snippets.

View YuukiNishikido's full-sized avatar

YuukiNishikido

View GitHub Profile
@YuukiNishikido
YuukiNishikido / UserCreate.ps1
Created April 15, 2024 09:23
読み込んだCSVの値に応じてActiveDirectory上にユーザーを作成するPowerShell
# 読み込む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にユーザーを作成する
@YuukiNishikido
YuukiNishikido / Create_Filelist.ps1
Last active April 12, 2024 10:12
PowerShell_特定のフォルダ配下のファイル一覧を大きいサイズ順にCSV出力する
###特定のフォルダ配下の全ファイルのファイルパスと容量を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
@YuukiNishikido
YuukiNishikido / o365認証情報ファイル生成.ps1
Created April 25, 2021 13:13
o365認証情報ファイル生成
$tmpCred = Get-Credential
$tmpCred.Password | ConvertFrom-SecureString | Set-Content "C:\xxx\pwd.dat"
@YuukiNishikido
YuukiNishikido / o365_です。
Last active April 25, 2021 13:15
AzureADメールエイリアス抽出
#予め作成した認証情報を取り込み
$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