Good night,
I´m having a hard time managing some resources and I´m trying to create scripts to streamline everyday tasks.
one of these tasks is to make the script identify the volumes and disks connected to a specific station called maintenance, in this station the disks are placed in a controller and automatically mapped to a drive letter, after that I need to perform simple maintenance tasks , such as chkdsk, antivirus, defragmentation and last VHD backup of the volume.
my problem is to reconcile the outputs of the get-disk and the get-volume in order to be able to separate the physical disks and their respective volumes, after that it would just be identifying the number of the OS to organize their backup on the server.
I leave an example of what I'm trying to do below:
PS C:\windows\system32> Get-Disk
Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition
Style
1 GLOWAY WAR... DA7C14D0440030031235 Healthy Online 223.57 GB GPT
0 WDC WD3200... WD-WMAV2M182177 Healthy Online 298.09 GB MBR
2 Generic ST... [ Healthy No Media 0 B RAW
1 = MY OS DISK
2 = MY FIRST DISK TO TEST
3 = USB CARD READER - NOT USED
PS C:\windows\system32> Get-Volume
DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size
NTFS Fixed Healthy OK 1.12 MB 450 MB
EFI NTFS Fixed Healthy OK 289.27 MB 350 MB
E Elaine - Docs NTFS Fixed Healthy OK 132.66 GB 197.6 GB
D Windows 7 Pro NTFS Fixed Healthy OK 12.87 GB 100.15 GB
G Unknown Removable Healthy Unknown 0 B 0 B
FAT32 Fixed Healthy OK 50.1 MB 95 MB
C NTFS Fixed Healthy OK 59.69 GB 223.02 GB
In this scenario above, I need the script to locate the non-OS disk, as I don't need to perform maintenance on it, and place Disk 2 in a service queue, but only the units related to Disk 2, but I don't know how to do this filter. by powershell
can someone help me in this matter?
the order you intend to execute would be this and the antivirus is Security essentials, the defragmenter is that of Windows itself and the backup is done by disk2vhd.
objective - disk maintenance, backup of the drives in their respective letters, antivirus, defragmentation, store by OS number