Import .reg files remotely with PowerShell and PSSession

Been into PowerShell and Automation for a while now.

#Creating PSCredential object Snippit
$User = “M-toTheI’ke”
$File = “\\Contra2\D$\Powershell\Password\Password.txt”
$MyCredential= New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $User, (Get-Content $File | ConvertTo-SecureString)

cls
#Build Session
$servers = Get-Content “c:\Powershell\Servers.txt”

Location of Registry file to import. Notice “.reg”
$RegFile = “\\Contra2\D$\Player2.reg”

foreach ($server in $servers)
{

<#Building a session for remote servers based on the content of the servers.txt #>
$Session = New-PSSession -computername $server -credential $MyCredential

<#Taking file from hosted location of file and forcing it to the built session #>
Copy-Item -Path “$RegFile” -Destination “C:\Utils\” -force -ToSession ` $session

#Validate File exists **Code here** NOT DONE

#Command to run the regedit to import the newly copied player2.reg
Invoke-Command -session $session -ScriptBlock {regedit /i /s C:\Utils\player2.reg}
}

 

Many ways to skin this but I can now use this to multiple remote servers as long as the WINRM port and services will accept the session remotely.

Posted in Powershell, Scripting | Comments Off on Import .reg files remotely with PowerShell and PSSession

New IIS Preview

I have a long love hate relationship with IIS and its iterations.

That said this looks awesome.

I setup a test that took like 5 min to setup. It does require an access token (that does expire).

More to come obviously.

Posted in ASP.NET, IIS, Microsoft, Web Development, Web Services | Leave a comment

Windows: Enable generation of 8.3 names

Windows: Enable generation of 8.3 NamesMichls Tech Blog

in newer Versios of Windows the generation of the DOS Style 8.3 names is disabled by default.

If you need this “feature” you can either enabled it globally on a system or on a per volumes basis.

Check the current state

D:\> fsutil.exe 8dot3name query
The registry state is: 2 (Per volume setting - the default).
D:\> fsutil.exe 8dot3name query D:
The volume state is: 1 (8dot3 name creation is disabled).
The registry state is: 2 (Per volume setting - the default).

Based on the above two settings, 8dot3 name creation is disabled on D:

To enable it for all volumes

D:\> fsutil 8dot3name set 0

Or for a specific volume

D:\> fsutil 8dot3name set D: 0

and to disable it

D:\> fsutil 8dot3name set D: 1

Posted in Uncategorized | Leave a comment