[GE] 이미지를 Word로 가져온 다음 규칙에 따라 이름(2/2)

5732 단어 word
# docx 
Set-ItemProperty -Path "e:\screenshot\*.docx" -Name IsReadOnly -Value $false
# 
$target = "e:\screenshot"
$pw = ConvertTo-SecureString ' ' -AsPlainText -Force
$Creds = New-Object -Typename System.Management.Automation.PSCredential -Argumentlist "tcsgegdc\814072", $pw
New-PSDrive -Name P -PSProvider FileSystem -Root "\\3.242.165.18\c$\screenshot" -Credential $Creds
Get-ChildItem -Path P:\ | Move-Item -Destination $target -Force
Remove-PSDrive -Name P
# 
$datetime = (Get-Date).Tostring("yyyyMMdd")
$lastday = ((Get-Date 0).AddYears((Get-Date).Year - 1).AddMonths((Get-Date).Month).AddDays(-1)).Day
switch($null) {
    {(Get-Date).Day -eq $lastday} {$filename = "Monthly backup " + $datetime}
    {(Get-Date).DayOfWeek -ne "Friday" -or "Saturday" -or "Sunday" -and (Get-Date).Day -ne $lastday} {$filename = "Daily backup " + $datetime}
    {(Get-Date).DayOfWeek -eq "Friday" -and (Get-Date).Day -ne $lastday} {$filename = "Weekly backup " + $datetime}
}
# Word 
$objWord = New-Object -ComObject Word.Application
$objWord.Visible = $false
$objDoc = $objWord.Documents.Add()
$objSelection = $objWord.Selection
$objShape = $objDoc.Shapes.AddPicture("e:\screenshot\$filename.JPEG")
$objDoc.SaveAs([ref]"e:\screenshot\$filename",[ref]16)
$objword.Quit()
# JPG 
#Get-ChildItem -path *.JPEG | Remove-Item

좋은 웹페이지 즐겨찾기