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 […]

Posted in KB-Powershell/CMD, KB-Windows, Knowledge Base | Comments Off on Delete folder via CMD on Windows

Export windows drivers on windows 10

open powershell as admin Export-WindowsDriver -Online -Destination C:\temp\driverexport You can then copy the drivers to another location to have a copy of them.   I have previously used this when reinstalling windows, where I export drivers to a USB, so when going to installed windows and then using device manager I browse to the Drivers […]

Posted in KB-Powershell/CMD, KB-Windows, Knowledge Base | Comments Off on Export windows drivers on windows 10

Assign/remove drive letter with CMD

Run command prompt as admin type diskpart list volume select volume (number of the one you want) To Assign assign letter=H to Remove remove letter=H

Posted in KB-Powershell/CMD, KB-Windows, Knowledge Base | Comments Off on Assign/remove drive letter with CMD

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 […]

Posted in KB - Server, KB - Windows Server, KB-HyperV, KB-Powershell/CMD, KB-Software, KB-Windows, Knowledge Base | Comments Off on Failover Cluster manager – get list of Vm’s and if a VM has a DVD (iso file)

Change the certificate used for remote desktop connection

wmic /namespace:\\root\CIMV2\TerminalServices PATH Win32_TSGeneralSetting Set SSLCertificateSHA1Hash=”CertificateSHA1Hash” You can get the Certificate SHA1 Hash by using openssl

Posted in KB - Windows Server, KB-Powershell/CMD, KB-Remote Desktop, Knowledge Base | Comments Off on Change the certificate used for remote desktop connection

force a network type in Windows using PowerShell

Let’s first get a look at the profile used by your network adapters: Get-NetConnectionProfile Find the InterfaceIndex number of the adapter you wish to change then use command: Set-NetConnectionProfile -InterfaceIndex <index number> -NetworkCategory Private

Posted in KB-Powershell/CMD, Knowledge Base | Comments Off on force a network type in Windows using PowerShell

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 […]

Posted in KB-HyperV, KB-Powershell/CMD, Knowledge Base | Comments Off on Hyper-V get VM VHD Used and Provisioned Storage

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 […]

Posted in KB - Security, KB-Office 365, KB-Powershell/CMD, Knowledge Base | Comments Off on Office 365 – check which mailboxes a particular user has access to

Use PowerShell to download a file

copy from network share Copy–Item –Source \\server\share\file –Destination C:\path\   Powershell $WebClient = New–Object System.Net.WebClient $WebClient.DownloadFile(“https://www.contoso.com/file”,“C:\path\file”)

Posted in KB-Powershell/CMD, Knowledge Base | Comments Off on Use PowerShell to download a file

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 […]

Posted in KB-Office 365, KB-Powershell/CMD, Knowledge Base | Comments Off on Search Exchange mailbox for a particular folder