Tag Archives: Powershell

WSUS Commands

wuauclt /detectnow

https://mcpmag.com/articles/2017/08/10/automate-wsus-using-the-powershell-updateservices.aspx

https://www.business.com/articles/powershell-windows-software-update-services/

WSUS Commands in Windows 10 / Server 2016:
https://omgdebugging.com/2017/10/09/command-line-equivalent-of-wuauclt-in-windows-10-windows-server-2016/

usoclient StartScan

WSUS in PowerShell:
https://docs.microsoft.com/en-us/powershell/module/wsus/get-wsusserver?view=win10-ps

Windows 10 1809 Optional Features (inc RSAT)

Windows 10 from 1809 onward, pulls optional features from WSUS so will show no available updates unless they are configured.

To get around this you can configure a PC to search online for available optional features…

Run “gpedit.msc” to edit your local computer policy The setting in question is: Computer Configuration\Administrative Templates\System\Specify settings for optional component installation and component repair

My local policy seems to have defaulted to “Disabled” – after changing it to “Enabled” and selecting the checkbox labeled “Download repair content and optional features directly from Windows Update instead of Windows Server Update Services (WSUS)” the RSAT tools installed for me.

Then you can powershell to get the updates you need e.g.:

Add-WindowsCapability –online –Name “Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0”

Check out this link for lots more options!

http://woshub.com/install-rsat-feature-windows-10-powershell/

Powershell Office 365 Mailbox Folder Permissions

Set-executionpolicy unrestricted
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session -allowclobber
Connect-MsolService -Credential $LiveCred

$Identity = "[email protected]:\Calendar"

#Remove-MailboxFolderPermission -Identity $Identity -User "A Bloke"

#Add-MailboxFolderPermission -Identity $Identity -User [email protected] -AccessRights Editor

Set-MailboxFolderPermission -Identity $Identity -User "Andrew Bloggs" -AccessRights Reviewer

Get-MailboxFolderPermission -Identity $Identity

Remote Disk Management

On the computer which you use to connect to the server core, run this command:
netsh advfirewall firewall set rule group="Remote Volume Management" new enable=yes

Or this powershell:
Enable-NetFirewallRule -name RVM-RPCSS-In-TCP,RVM-VDSLDR-In-TCP,RVM-VDS-In-TCP

….ON BOTH THE SOURCE AND TARGET MACHINES!!!

https://blogs.technet.microsoft.com/wincat/2012/05/02/what-needs-to-be-configured-to-do-remote-disk-management-of-a-server-core-installation-in-windows-server-2012-via-powershell/

https://social.technet.microsoft.com/Forums/windowsserver/en-US/22ca1d25-05b5-416c-bf9b-b301a2065d31/forum-faq-when-you-use-disk-management-to-connect-to-a-remote-computer-in-the-same-domain-you?forum=winserverfiles

Powershell Input Validation

https://gallery.technet.microsoft.com/scriptcenter/PowerShell-Input-Validation-30ebaa51

Function Validate-PostalCode
{
Param([Parameter(Mandatory=$true,HelpMessage="Enter a valid Postal Code xxx-xxx-xxxx")][ValidatePattern("[0-9][0-9][0-9][0-9]")]$PostalCode)
Write-host "The Pin Code $PostalCode is valid"
}

Function validate-PhoneNumber
{
Param([ValidatePattern("\d{3}-\d{3}-\d{4}")]$phoneNumber)
Write-host "The phone number $phoneNumber is valid"
}


validate-PhoneNumber -Phonenumber 999-999-9999

function Validate-Email ([string]$Email)
{
return $Email -match "^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"
}

function Validate-IPAddress ([string]$IP)
{
if($IP -match "(\d{1,3}).(\d{1,3}).(\d{1,3}).(\d{1,3})" -and -not ([int[]]$matches[1..4] -gt 255))
{
Write-host "The $IP IP is valid"
}
}

function Validate-Filename
{
Param([ValidatePattern("^\d{8}_[a-zA-Z]{3,4}_[a-zA-Z]{1}\.jpg"]$filename)
Write-host "The filename $filename is valid"
}