본문 바로가기

파워쉘(Powershell)44

Get-ADComputer - Active Directory에서 컴퓨터 정보 읽기 Get-ADComputer를 사용하면 액티브 디렉토리에 있는 컴퓨터 정보를 읽을 수 있습니다  computers.txt에 저장된 컴퓨터 이름을 하나씩 읽어서 Name, CanonicalName을 out.csv 파일에 저장하는 방법computers.txt computer1computer2computer3 New-Item .\out.csv -ForceAdd-Content -Path .\out.csv -Value "Name,canonicalname"Get-Content .\computers.txt | %{ $comName = $_ try{ Get-ADComputer $comName -Properties canonicalname | Select-Object Name, canonicalna.. 2024. 6. 27.
파워쉘-엑셀파일 읽기 $fileName = 'c:\powershell\test.xlsx' $objExcel = New-Object -ComObject Excel.Application $WorkBook = $objExcel.Workbooks.Open($fileName) $workSheet = $Workbook.Sheets.Item(1) Write-Host $workSheet.Cells.Item(1,1).Text Write-Host $workSheet.Cells.Item(1,2).Text Write-Host $workSheet.Cells.Item(1,3).Text Write-Host $workSheet.Cells.Item(2,1).Text Write-Host $workSheet.Cells.Item(2,2).Text Write-H.. 2024. 4. 22.
파워쉘-원격 파일서버들의 공유폴더들 권한 읽기 원격 파일서버들의 모든 공유 폴더들의 permission 정보 읽는 방법 서버 이름으로 worksheet 만들고, 각 폴더의 공유권한 정보를 엑셀에 출력 $excel = New-Object -ComObject Excel.Application $excel.Visible = $true $workbook = $excel.Workbooks.add() #$servers = 'File_Server-1' #서버 한 대 #$servers = Get-Content .\Servers.txt # Servers.txt 파일에 저장된 서버들 목록 갖고오 $servers = 'File_Server-1','File_Server-2','File_Server-3' ForEach($com in $servers){ Write-host $.. 2024. 4. 19.
파워쉘 - 엑셀(Excel)에 쓰기 엑셀 실행후 데이터 넣기 $excel = New-Object -ComObject Excel.Application $excel.Visible = $true $workbook = $excel.Workbooks.add() $sheet = $workbook.worksheets.Add() $sheet.Name = "First" $sheet.Cells.Item(1,1) = '1,1' $sheet.Cells.Item(1,2) = '1,2' $sheet.Cells.Item(2,1) = '2,1' Cell 색깔 바꾸기 $sheet.Cells.Item(1,1) = '1,1' $sheet.Cells.Item(1,1).Interior.ColorIndex = 44 Color Index 사용예 $excel = New-Object.. 2024. 4. 19.