aaa
This commit is contained in:
@@ -20,20 +20,28 @@
|
|||||||
when:
|
when:
|
||||||
- freediskspace.stdout | trim | float < 20
|
- freediskspace.stdout | trim | float < 20
|
||||||
|
|
||||||
- name: Find Recovery partitions and sizes (MB)
|
- name: Find Recovery partitions (PowerShell → JSON)
|
||||||
ansible.windows.win_powershell:
|
ansible.windows.win_powershell:
|
||||||
script: |
|
script: |
|
||||||
$guid = '{DE94BBA4-06D1-4D40-A16A-BFD50179D6AC}'
|
$guid = '{DE94BBA4-06D1-4D40-A16A-BFD50179D6AC}'
|
||||||
$parts = Get-Partition |
|
$parts = @( Get-Partition |
|
||||||
Where-Object {
|
Where-Object { $_.GptType -eq $guid -or $_.Type -eq 'Recovery' -or $_.Type -eq 'Unknown' } |
|
||||||
$_.GptType -eq $guid -or $_.Type -eq 'Recovery' -or $_.Type -eq 'Unknown'
|
Select-Object DiskNumber, PartitionNumber,
|
||||||
} |
|
@{n='SizeBytes';e={$_.Size}},
|
||||||
Select-Object DiskNumber, PartitionNumber,
|
@{n='SizeMB';e={[math]::Round($_.Size/1MB,2)}},
|
||||||
@{n='SizeMB';e={[math]::Round($_.Size/1MB,2)}},
|
GptType, Type )
|
||||||
GptType, Type
|
$parts | ConvertTo-Json -Compress -Depth 4
|
||||||
$parts | ConvertTo-Json -Compress
|
register: winre_raw
|
||||||
register: winre_parts
|
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:
|
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