After installing Docker for Windows I was unable to run it, following error appeared.
Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The specified module 'Hyper-V' was not loaded because no valid module file was found in any module directory.
at <ScriptBlock>, <No file>: line 76
at Docker.Backend.HyperV.RunScript(String action, Dictionary`2 parameters)
at Docker.Backend.ContainerEngine.Linux.Start(Settings settings)
at Docker.Core.Pipe.NamedPipeServer.<>c__DisplayClass8_0.<Register>b__0(Object[] parameters)
at Docker.Core.Pipe.NamedPipeServer.RunAction(String action, Object[] parameters)</pre>
I checked that Hyper-V was installed but it seems that Docker also needs to have the Powershell tools installed. So activate the feature and Docker will run fine 🙂
The other day I had to increase the memory of 30 virtual servers and install the latest VMWare tools. Instead of doing this manually I uses PowerCLI.
Put the serverlist in a *.txt file that is located in the same folder as the PowerShell script. This will shutdown the server, increase the RAM to 4GB, start the server and then upgrade the VMWare tools.
$servers = Get-Content -Path E:\path_to_my_folder\server_list.txt
get-vm $servers | Shutdown-VMGuest –Confirm:$False
sleep 150
Get-VM $servers | Set-VM –MemoryGB 4 –Confirm:$False | Start-VM
sleep 120
Get-VM $servers | Update-tools -RunAsync
This script is created to count how many folders exist in a NAS Share. It loads the list from SQL Server and writes the result back to the same table. You can modify it to your own needs.
# **********************************************
# Created by SĂ©bastien Morel
# http://blog.elmore.be
# Last update: August 26th, 2010
# Version 1.00
#
# This script will loop NAS Folders
# and return number of homefolders per share
# **********************************************
# retrieve NAS Folders
$sqlsvr = '<MySQLServer>'
$database = '<MySQLDB>'
$table = 'tbl_homeshares_trees'
Clear-Host
Write-Host "Please wait a moment, this can take a while..."
Write-Host " "
#Create SQL Connection
Write-Verbose "Creating SQL Connection..."
$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=$sqlsvr;Initial Catalog=$database; Integrated Security=SSPI")
$conn.Open()
$conn2 = New-Object System.Data.SqlClient.SqlConnection("Data Source=$sqlsvr;Initial Catalog=$database; Integrated Security=SSPI")
$conn2.Open()
$cmd = $conn.CreateCommand()
$cmd2 = $conn2.CreateCommand()
$cmd.CommandText = "select tree_id, tree_path from $table"
$Reader = $cmd.ExecuteReader()
while ($Reader.Read()) {
$sID = $Reader["tree_id"].Tostring()
$sPath = $Reader["tree_path"].Tostring()
Write-Host "Querying $sPath..."
$sGo = Get-ChildItem $sPath
# update table
$cmd2.CommandText = "UPDATE $table SET tree_count = " + $sGo.Count + " WHERE tree_id = '" + $sID + "'"
$cmd2.ExecuteNonQuery() | Out-Null
}
$conn.Close()
$conn2.Close()
$Reader.Close()
The results in the database
Classical script and we all need it some day. Edit the folder path and adjust the number of days to your clean-up schedule. The script works recursive so it will also clean-up subfolders.
As always, make sure you can execute PowerShell scripts
Set-ExecutionPolicy RemoteSigned
The Script…
$Now = Get-Date
$Days = "30"
$TargetFolder = "C:WINDOWSsystem32LogFiles"
$LastWrite = $Now.AddDays(-$days)
$Files = get-childitem $TargetFolder -include *.log, *.txt -recurse | Where {$_.LastWriteTime -le "$LastWrite"}
foreach ($File in $Files){
write-host "Deleting File $File" -foregroundcolor "Red"; Remove-Item $File | out-null
}
WMI was in the past commonly used for scripting tasks and sometimes it handy to know which classes are installed on a server/workstation. Today I found a WMI GUI that was written in Powershell by Marc van Orsouw. He has a blog called The PowerShell Guy and you can download it from here!
Windows Management Framework, which includes Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0, was officially released to the world this morning. By providing a consistent management interface across the various flavors of Windows, we are making our platform that much more attractive to deploy. IT Professionals can now easily manage their Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2 machines through PowerShell remoting – that’s a huge win!
You can download the packages here: http://go.microsoft.com/fwlink/?LinkID=151321
It might be usefull to know which version of Powershell is installed on your server / desktop.
Open a dos-prompt and then open a PowerShell session. There are 3 ways to check the installed version
Method 1
$Host.Version
Method 2
get-host
Method 3 (works only with v2)
$PSVersionTable
Recent Comments