Delete folder via CMD on Windows

run command prompt as admin cd to the location of folder DEL /F/Q/S *.* > NUL    (this deletes all files all the folder structure) used cd.. to navigate to parent folder RMDIR /Q/S foldername (this deletes the folder and all subfolders) DEL /F/Q/S *.* > NUL /F -- forces the deletion of read-only files. /Q -- enables quiet mode. You are not ask if it is ok to delete files (if you don't use this, you are asked for any file in the folder). /S -- runs the command on all files in any folder under the selected structure. *.* -- delete all files. > NUL -- disables console output. This improves the process further, shaving off about one quarter of the processing time off of the console command. RMDIR /Q/S foldername /Q -- Quiet mode, won't prompt for confirmation to delete folders. /S -- Run the operation on all folders of the selected path. foldername -- The absolute path or relative folder name, e.g. o:/backup/test1 or test1...
Read More

Failover Cluster manager – get list of Vm’s and if a VM has a DVD (iso file)

Powershell Get-ClusterGroup -Cluster 19-hv | ? {$_.GroupType –eq 'VirtualMachine' } | Get-VM | Get-VMDvdDrive   19-hv is the cluster name I have created VMName ControllerType ControllerNumber ControllerLocation DvdMediaType Path ------ -------------- ---------------- ------------------ ------------ ---- 19-RDSH SCSI 0 1 None 2016DC-1 SCSI 0 1 None 2019 SCSI 0 1 None Android IDE 1 0 ISO \\fs1\OS\Linux\android-x86-5.1-rc1.iso AzureADConnect2 SCSI 0 1 None CentOS-G1 IDE 1 0 None Domonitor SCSI 0 1 None exchange IDE 1 0 None FireflyIII IDE 1 0 None G2-testboot SCSI 0 1 None GMVault SCSI 0 1 None GW2 SCSI 0 1 None JenkinsTestServer IDE 1 0 None LanSweep SCSI 0 1 None leSSL1 IDE 1 0 None MCS2(Toms Server) IDE 1 0 None MCS3 SCSI 0 1 None MCS4 SCSI 0 1 None Mgmt1 SCSI 0 1 None MineOS-G1 IDE 1 0 None Observium SCSI 0 1 None ODSPSync SCSI 0 1 None PFsense SCSI 0 1 None PFSenseG1 IDE 1 0 None Proxmox-G1 IDE 1 0 None SharePoint 2019 SCSI 0 1 None Sharepoint1 SCSI 0 1 None SQL SCSI 0 1 None Steam-Cache SCSI 0 1 None SYSDeploy SCSI 0 2 None SYSDEPLOY1 IDE 1 0 None SYSWebM1 IDE 1 0...
Read More

Hyper-V get VM VHD Used and Provisioned Storage

Open Powershell as admin   Get-VM | ForEach { $Vm = $_; $_.HardDrives } | ForEach { $GetVhd = Get-VHD -Path $_.Path [pscustomobject]@{ Vm = $Vm.Name Name = $_.Name Type = $GetVhd.VhdType ProvisionedGB = ($GetVhd.Size / 1GB) CommittedGB = ($GetVhd.FileSize / 1GB) } } | Export-Csv -Delimiter ";" -Path "C:\temp\VMVHDStorageUsedTotal.csv"   Creates CSV with data in one column, select column in excel, go to data tab, then text to columns > Delimiter > Semicolon Excel file would look like this: Vm Name Type ProvisionedGB CommittedGB GW1 Hard Drive on IDE controller number 0 at location 0 Dynamic 60 45.12890625 GW2 Hard Drive on SCSI controller number 0 at location 0 Dynamic 40 28.97265625 ...
Read More

Office 365 – check which mailboxes a particular user has access to

Connect to 365 via powershell $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session -DisableNameChecking.   Get-Mailbox | Get-MailboxPermission -User userA UserA would be the user that you want to know for instance; What mailboxes does Matt have access to would be as follows: Get-Mailbox | Get-MailboxPermission -User matt  ...
Read More

Search Exchange mailbox for a particular folder

Connect to 365 via powershell $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session -DisableNameChecking. Get-MailboxFolderstatistics -Identity mailboxname | Where {$_.Name -Match "foldername"} For instance to search my mailbox name Matt for a folder that contains alerts the command looks like this: PS C:\WINDOWS\system32> Get-MailboxFolderstatistics -Identity matt | Where {$_.Name -Match "alerts"} Although this give the output below, If you have multiple folders that contain your search criteria it can be difficulty to read To get a better idea of where the folder is located use the identity to filter PS C:\WINDOWS\system32> Get-MailboxFolderstatistics -Identity matt | Where {$_.Name -Match "alerts"} | select identity Identity -------- matt\LanSweeperAlerts Another example is a folder called backups that is within my inbox folder PS C:\WINDOWS\system32> Get-MailboxFolderstatistics -Identity matt | Where {$_.Name -Match "backups"} | select identity Identity -------- matt\Inbox\Backups Once you have finished disconnect your exchange powershell session Remove-PSSession $Session...
Read More