OS 윈도우 8, Windows 작업 8을 사용하여 CSV 파일로 가져 오기 위해 디스크 공간을 가져 오기 위해 스크립트를 예약하고 있습니다. 스크립트는 수동으로 실행되지만 예약 된 경우 작업 스케줄에 따라 출력되지 않습니다. 사용 된 코드는 다음과 같습니다.Powershell Scheduling Diskspaces 가져 오기
Set-ExecutionPolicy Unrestricted -Force
$filepath = "C:\Users\asdf\Downloads\Powershell\CheckFreeSpaceV3"
$servername = "abc"
#delete reports older than 7 days
$OldReports = (Get-Date).AddDays(-7)
#Removing Report older than 7 Days
Get-ChildItem $filepath\DiskReport*.* | `
Where-Object { $_.LastWriteTime -le $OldReports} | `
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
#Create variable for log date
$LogDate = get-date -f yyyyMMddhhmm
$DiskReport = Get-WmiObject win32_logicaldisk `
-ComputerName $servername -Filter "Drivetype=3" `
-ErrorAction SilentlyContinue |
#return only disks with free space less than or equal to 0.1 (40%)
Where-Object { ($_.freespace/$_.size) -le '0.4'}
#Create Reports
$DiskReport |
Select-Object @{Label = "Server Name";Expression = {$_.SystemName}},
@{Label = "Drive";Expression = {$_.DeviceID}},
@{Label = "Total Space(GB)";Expression = {"{0:N1}" -f($_.Size/1gb)}},
@{Label = "Free Space (GB)";Expression = {"{0:N1}" -f($_.Freespace/1gb) }},
@{Label = 'Free Space (%)'; Expression = {"{0:P0}" -f ($_.freespace/$_.size)}} |
I put the following arguments in taskschdular arguments
-NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File powershell_Script_path
감사 Ranadip, 난, 작업 schedular에서 스크립트를 일정에 문제가 있지만 일정 할 때 작동하지 않습니다. –
@AhmadRaza : powershell을 통해 예약 된 작업을 생성하는 다른 스크립트를 붙여 넣습니다. 요구 사항에 따라 스크립트 경로와 추가 세부 정보를 변경하십시오. Answers에 만족한다면 그것을 좋아하십시오. 그것은 견해를 증가시키고 다른 사람들을 도울 것입니다. –