[파워쉘]텔레그램 푸시
# Script/Powershell2018. 8. 21. 09:48[파워쉘]텔레그램 푸시

아래 내용 test.ps1로 저장 $token = "#########################" $chatId = "################" $message = $args Invoke-RestMethod -Uri "https://api.telegram.org/bot$token/sendMessage?text=$message&chat_id=$chatId" 실행 powershell -executionpolicy bypass test.ps1 테스트~~~

[파워쉘]파일 마지막 쓰기한 날짜변경
# Script/Powershell2017. 3. 5. 18:23[파워쉘]파일 마지막 쓰기한 날짜변경

# 변경할 날짜지정 $d = Get-Date "02/09/2013 4:59 PM" # 변경할 파일 대상 지정 $f = Get-Item "C:\test\test.txt" # 변경할 파일에 변경할 날짜 적용 $f.LastWriteTime = $d 출처 : http://stackoverflow.com/questions/21630424/modifying-lastwritetime-directory-in-powershell

[파워쉘]VBS로 파워쉘 실행
# Script/Powershell2017. 3. 5. 18:22[파워쉘]VBS로 파워쉘 실행

ps="powershell.exe -nologo -command " & Chr(34) & "[xxxx.ps1]" & Chr(34) set shell=createobject("WScript.Shell") shell.Run ps,0,true 출처 : http://kernel64.tistory.com/567

[파워쉘]특정날짜 지난 폴더(하위폴더 포함) 삭제
# Script/Powershell2016. 12. 21. 14:28[파워쉘]특정날짜 지난 폴더(하위폴더 포함) 삭제

1. 현재날짜보다 3일이전 날짜를 변수로 저장 $deleteday = (get-date).adddays(-3).tostring("yyyyMMdd") 2. 정리할 폴더 위치를 변수 저장 $deletedir = "C:\templog" 3. 현재 날짜를 기준으로 지정된 날짜 전에 폴더를 삭제 get-childitem -path $deletedir| where-object {$_.name -le $deleteday} | remove-item -recurse -force 단, 파일명이 길경우는 위와 같이 진행시 오류가 발생합니다 ㅜ_ㅜ 4. delete_folder.ps1파일로 저장 $del_dir = get-childitem -path $deletedir| where-object {$_.name -le $del..

[파워쉘]파일내 특정문자열 치환
# Script/Powershell2016. 3. 15. 13:20[파워쉘]파일내 특정문자열 치환

파워쉘을 이용한 파일내 치환방법은 아래와 같습니다. get-content 대상파일 | %{$_ -replace ('기존내용','변경할 내용')} 지정된 파일내에 특정문자를 치환하지만 실제로 파일에 저장되진 않습니다. 변수명 =get-content 대상파일 | %{$_ -replace ('기존내용','변경할 내용')} 변수명 > 대상파일 실행파일 명령어를 변수로 저장하여 리다이렉션시키면 치환했던 내용으로 저장할수가 있습니다.

image