aaa
This commit is contained in:
@@ -20,20 +20,28 @@
|
||||
when:
|
||||
- freediskspace.stdout | trim | float < 20
|
||||
|
||||
- name: Find Recovery partitions and sizes (MB)
|
||||
- name: Find Recovery partitions (PowerShell → JSON)
|
||||
ansible.windows.win_powershell:
|
||||
script: |
|
||||
$guid = '{DE94BBA4-06D1-4D40-A16A-BFD50179D6AC}'
|
||||
$parts = Get-Partition |
|
||||
Where-Object {
|
||||
$_.GptType -eq $guid -or $_.Type -eq 'Recovery' -or $_.Type -eq 'Unknown'
|
||||
} |
|
||||
$parts = @( Get-Partition |
|
||||
Where-Object { $_.GptType -eq $guid -or $_.Type -eq 'Recovery' -or $_.Type -eq 'Unknown' } |
|
||||
Select-Object DiskNumber, PartitionNumber,
|
||||
@{n='SizeBytes';e={$_.Size}},
|
||||
@{n='SizeMB';e={[math]::Round($_.Size/1MB,2)}},
|
||||
GptType, Type
|
||||
$parts | ConvertTo-Json -Compress
|
||||
register: winre_parts
|
||||
GptType, Type )
|
||||
$parts | ConvertTo-Json -Compress -Depth 4
|
||||
register: winre_raw
|
||||
changed_when: false
|
||||
|
||||
- name: Show results
|
||||
- name: Parse JSON to a list
|
||||
ansible.builtin.set_fact:
|
||||
winre_parts: >-
|
||||
{{ (winre_raw.output | join('') | trim) | default('[]') | from_json }}
|
||||
|
||||
- name: Show Recovery partition sizes
|
||||
ansible.builtin.debug:
|
||||
var: winre_parts.output | from_json
|
||||
msg: >-
|
||||
Disk {{ item.DiskNumber }}, Partition {{ item.PartitionNumber }},
|
||||
Size: {{ item.SizeMB }} MB ({{ item.SizeBytes }} bytes)
|
||||
loop: "{{ winre_parts }}"
|
||||
Reference in New Issue
Block a user