Powershell – Michael Groff /blog Expand or Die Wed, 04 Dec 2019 16:59:20 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 Cmdlet for PowerCLI to load vCenter & esxi Hosts /blog/cmdlet-for-powecli-to-load-vcenter-esxi-hosts/ Wed, 24 May 2017 20:46:53 +0000 /blog/?p=822

Powershell & PowerCLI Prep

#Set Execution Policy

Set-ExecutionPolicy RemoteSigned

#Ignore SSL Certificates warnings

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -WarningAction SilentlyContinue

#Connecting to server & save creds:

Connect-VIServer vCenter.DOMAIN.com -User DOMAIN\Administrator -Password -SaveCredentials

#Location to open up PowerCLI normally:

. "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"

CMDLET

function Load-PowerCLI
{
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
Add-PSSnapin VMware.VumAutomation -ErrorAction SilentlyContinue
Add-PSSnapin VMware.DeployAutomation -ErrorAction SilentlyContinue
Add-PSSnapin VMware.DeployAutomation -ErrorAction SilentlyContinue
& "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
Write-Host "================================================" -ForegroundColor White
Write-Host "
...connecting to vCenter servers
"
Connect-VIServer vCenter0.groffbox.com
}

BONUS:

Set the VMConsole to open correctly with Open-VMConsole Window

#Download and Install 32-bit Firefox, you NEED 32-bit
#Run:

Set-PowerCLIConfiguration –VMConsoleWindowBrowser “C:\Program Files (x86)\Mozilla Firefox\firefox.exe”

Now you can run Open-VMConsoleWindow

]]>
PS Script install WP manually on Server 2012 R2 /blog/ps-script-install-wp-manually-server-2012-r2/ Thu, 14 Jul 2016 22:23:07 +0000 /blog/?p=548

This post does basically the same thing that I have already covered in my “WordPress on IIS 8.5 (Windows 2012 R2)” post, but it is a script that does literally everything for you. You will just need to add in a few of your own settings into the script, run it, and you will have a functional WP site.

First lets start of with the Features that I already have installed:

You will most likely have all of these but Telnet… INSTALL TELNET!

 

DisplayName                                   Name                      InstallState
-----------                                   ----                      ------------
File and Storage Services                     FileAndStorage-Services      Installed
Storage Services                              Storage-Services             Installed
.NET Framework 4.5 Features                   NET-Framework-45-Features    Installed
.NET Framework 4.5                            NET-Framework-45-Core        Installed
WCF Services                                  NET-WCF-Services45           Installed
TCP Port Sharing                              NET-WCF-TCP-PortSharing45    Installed
SMB 1.0/CIFS File Sharing Support             FS-SMB1                      Installed
Telnet Client                                 Telnet-Client                Installed
User Interfaces and Infrastructure            User-Interfaces-Infra        Installed
Graphical Management Tools and Infrastructure Server-Gui-Mgmt-Infra        Installed
Server Graphical Shell                        Server-Gui-Shell             Installed
Windows PowerShell                            PowerShellRoot               Installed
Windows PowerShell 4.0                        PowerShell                   Installed
Windows PowerShell ISE                        PowerShell-ISE               Installed
WoW64 Support                                 WoW64-Support                Installed

 

NOTES:

  • Use https://api.wordpress.org/secret-key/1.1/salt/ to generate your Salt Keys… After they have been generated, you must replace any “$” character with any other character. Not just this script, but WordPress will not work if there is a “$” character in the salt keys.
  • You will be asked for some variables, they are as follows:
Variable Example
IIS Site Name MyWordpressSite.com
IIS App Pool Name MyWordpressSite.com
Directory Path for website C:\inetpub\wwwroot\MyWordpressSite
Database Name wordpress612
Database Username wordpressuser612
Database Password mysecretpassword612
MySQL root Password v9gvBhTG@*b6n#^!v
FTP Username FTPUser
FTP Password FTPPass123!
  • You can download check out the progress of the script on my Github and you can download it with the following icon:

ps1_Icon

Now for the Script

<# 

    .SYNOPSIS
    Install a new WP site with all pre-reqs using pre-set variables. Can be used for additional sites.
    
    .DESCRIPTION
    This script will create a WordPress site with known-working configurations.
    Script can also be used to add additional sites as checks are in place. 
    To customize site, update custom variables as desired. 
    CAUTION - this script will overwrite a current site
        
    .OUTPUTS  
    A new wp site ready for your configuration! ;-)
     
    .NOTES
    Author: Michael Groff
    Minimum OS: 2012, 2012 R2
    PS Version: 4.0
    Date:  1/12/17
    
#>

#Checking Powershell Version

$LocalPSVers = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine\").PowerShellVersion | Where-Object {$_ -gt "4"}

IF (-not$LocalPSVers)
{
    Write-Host "
You need to upgrade to atleast PS Verion 5 before running this script!
" -ForegroundColor Red
    Read-Host "Press enter to exit"
    BREAK
}
ELSE
{
    Write-Host "
Correct Powershell Version found, you are good to go!
    " -ForegroundColor Green
}

###
###Variables Start: 
###
#Site Name, must inclue the TLD (.com, .info, .net, etc.)
Write-Host "
The website name, must inclue the TLD (.com, .info, .net, etc.)
" -ForegroundColor Yellow
$iisAppName = Read-host -prompt "Enter the website name"
#IIS App Pool Name: 
Write-Host "
The iis app pool name, can be same as website
" -ForegroundColor Yellow
$iisAppPoolName = Read-host -prompt "Enter the iis app pool name, can be same as website"
#Site Path
Write-Host "
The suggested website root directory path is 'C:\inetpub\wwwroot\MyWordpressSite'
" -ForegroundColor Yellow
$directoryPath = Read-host -prompt "Enter the Website root directory path"
#Database Name
Write-Host "
The WordPress Database is a MySQL Database
" -ForegroundColor Yellow
$dbn = Read-host -prompt "Enter the WordPress Database Name"
#Database Username
Write-Host "
The WordPress Database User is a MySQL User
" -ForegroundColor Yellow
$dbun = Read-host -prompt "Enter the WordPress Database Username"
#Database User Password
Write-Host "
The WordPress Database Password should be a strong password, minimum 12 characters
" -ForegroundColor Yellow
$dbpw = Read-host -prompt "Enter the WordPress Database User Password"
#MySQL root password
Write-Host "
The  MySQL root password, this will create one if it doesnt exist
" -ForegroundColor Yellow
$MySQL = Read-host -prompt "Enter the MySQL root password"
#Salt Keys - https://api.wordpress.org/secret-key/1.1/salt/ (NOTE: Replace any $ that you see with another character!)
#Authentication Key
$AuthKey = "ry=,b*Gp,+1-voDYM`zq#:S_^ODN Lp9:_:&D5o6C%0SXsyi

		
]]>