What Does MoRef Mean or Refer to?

Question
What does MoRef mean?

Answer
It is a portmanteau of “Managed Object Reference.” It is a data type that comes up in the context of alerts/alarms in vSphere.

(The answer was adapted from page 152 of PowerCLI Cookbook by Sellers.)

“MoRefs are unique identifiers assigned to objects at the time of their creation.” (Taken from page 202 of PowerCLI Cookbook by Sellers.)

How Do You Find out if UAC is Enabled on Your Windows Computer?

Problem scenario
You are using either Windows Server 2019 or Windows 10. You want to know if UAC is enabled or not. What should you do?

Solution
Open PowerShell. Run this:

If((Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System).EnableLUA -eq 1) { echo “UAC is enabled”} Else {echo “UAC is NOT enabled”}

How Do You Install Windows DSC on Windows Server 2019?

Problem scenario
You are running Windows Server 2019. You want to install Windows DSC. What do you do?

Solution

  1. Open PowerShell.
  2. Run this command: Install-Module ‘PSDscResources’ -Verbose
  3. When prompted with this question “NuGet provider is required to continue…”, choose “Yes”.
  4. If you believe your Windows Server is in a secure environment, or you have no goals putting sensitive data on your Windows server,

How Do You Connect over Port 5986 on a Windows Server?

Problem scenario
Port 5986 is blocked from your Linux server to your Windows server. You have used the nmap command and see that it is filtered. You believe there are no intermediate firewalls or OS firewalls blocking this port. What should you do?

Solution
This assumes you have no firewall blocking port 5986 for incoming connections to the Windows server. nmap will report 5986 is filtered despite there being nothing blocking this port if wsman’s listener has not been properly configured.*

  1. Run this script on the Windows server:

$hostName = $env:COMPUTERNAME
$serverCert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName $hostName
Export-Certificate -Cert $serverCert -FilePath c:\vagrant\PsRemoting-Cert1.cer
Get-ChildItem c:\vagrant\PsRemoting-Cert1.cer
Enable-PSRemoting -Force
New-Item -Path WSMan:\localhost\Listener\ -Transport HTTPS -Address * -CertificateThumbPrint $serverCert.Thumbprint -Force

  1. That is it.

How Do You Run a Bolt Command from a Linux Server to a Windows Server?

Problem scenario
You want to run a PowerShell script or run an interactive command on a Windows server. You have Puppet Bolt installed on a Linux server. You do not need to use SSL. What do you do?

Solution
Run a command like this (but substitute x.x.x.x with the IP address of the Windows server, jdoe with the username and coolpassword with jdoe’s password):

bolt command run “Get-Process” –Targets winrm://x.x.x.x –no-ssl –user jdoe –password coolpassword

To run a script called “cool.ps1”,

A List of PowerShell Books

1593279183PowerShell for Sysadmins: Workflow Automation Made Easy by No Starch Press

1617294160Learn Windows PowerShell in a Month of Lunches by Manning Publications

1449320686Windows PowerShell Cookbook: The Complete Guide to Scripting Microsoft’s Command Shell by O’Reilly Media

1789536669Mastering Windows PowerShell Scripting: Automate and manage your environment using PowerShell Core 6.0, 3rd Edition by Packt Publishing

B085RQNL9XWindows PowerShell and Scripting for Beginners: Complete Beginners Guide to learn Windows PowerShell and its Scripting by Independently published

1617295094Learn PowerShell Scripting in a Month of Lunches by Manning Publications

0735675112Windows PowerShell Step by Step by Microsoft Press

1789808537Windows Server 2019 Automation with PowerShell Cookbook: Powerful ways to automate and manage Windows administrative tasks,