Alle berichten van RobinP

Multiple PowerShell outputs within Ivanti Automation

imageIvanti Automation (formally known as RES Automation) and PowerShell work very well together. By using PowerShell from within Ivanti Automation we are able to talk to any system that utilize a REST full API.

The Task for Powershell does only allow for all the screen output of a script to be placed in one Automation parameter. To divide this output into multiple parameters the data had to be splited in Automation or in Ivanti Identity Director.

image

Lees verder Multiple PowerShell outputs within Ivanti Automation

Using special characters in PowerShell Variables

PowerShellPowerShell is an important part of today’s IT landscape. By using PowerShell you can manage systems from different vendors in a unified way. Nowadays more and more vendors come with there own PowerShell cmdlets, PowerShell is way more than just another tool for today’s sysadmins. Today more then ever IT pros should me getting onboard the PowerShell train. It reminds me of a presentation I saw a couple of years ago where the presenter urged the attendees to ether learn PowerShell today or learn how to say the phrase “Do you want to have fries with that?”.

I am not sure if it is going to be like that. If you like scripting, learning PowerShell can be allot of fun. People often ask how to start learning PowerShell since there is so much to learn and there is allot of content on the subject online. My advice if you want to learn PowerShell today would be: https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-second-edition

This is a good way to learn the fundamental basics and guide you through the first steps in the world called PowerShell.

Today I want to talk about naming your variables, you want the name to identify its purpose so you can still tell what it does when you revisit your script a year later.

What characters can you use for naming a variable? To start off you can use all the alphanumeric characters, both capital letters and small letters.

Lees verder Using special characters in PowerShell Variables

Change the date to the EPOCH format

For a recent project it is a requirement to change a date value to the EPOCH format. We need this EPOCH date format to automate the creation of a ticket in a Remedy system. The customer is using BMC Atrium Orchestration as a frontend to the Remedy system.

What is EPOCH Time?
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).

Why does EPOCH time start in 1970?
So no file can be created before 1970-01-01. … Unix was originally developed in the 60s and 70s so the “start” of Unix Time was set to January 1st 1970 at midnight GMT (Greenwich Mean Time) – this date/time was assigned the Unix Time value of 0. This is what is know as the Unix Epoch.

I’ve created a small PowerShell function to convert a Get-Date input to the EPOCH date/time format.

function ConvertTo-Epoch ([datetime]$InputEpoch) {
    [datetime]$Epoch = '1970-01-01 00:00:00'
    [int]$Ctime = ""

    $Ctime = (New-TimeSpan -Start $Epoch -End $InputEpoch).TotalSeconds
    return $Ctime
}

$a = ConvertTo-Epoch (get-date)

Telnet with PowerShell via RES One Automation

Today I want to build an PowerShell script for a customer that will connect via Telnet to a switch or a firewall to run some commands and log the output. The next step is to be able to schedule this script to run at the beginning and at the end of the working day. The environment for this task is PowerShell 2.0 and RES ONE Automation 2015.

After some Internet searching I found an Get-Telnet PowerShell function that can do what I want. It will connect to the switch, and I can place the commands I want to run in an array or in a text file. I altered the script slightly to meet my needs. I only use the function because I run the script from within RES One Automation.

Lees verder Telnet with PowerShell via RES One Automation

Starting PowerShell as default within Windows Core

My lab environment runs on Windows 2012 R2 Core, with Hyper-V installed. It runs smoothly. When I need to manage the environment I can do the most common task right there on the prompt.

But with Microsoft pushing everyone to use PowerShell I don’t understand why Windows Core start with a normal prompt instead of a PowerShell prompt.

In this article I will describe how you can change the prompt that is launched when Windows Core boots from CMD to PowerShell.

In Windows Core there is no explore. All you get to see is al black command box..

Schermafdruk 2014-08-11 20.53.59

Now let’s see if we can find out how to change the cmd prompt to a PowerShell prompt.
First I need to know what’s the current value for the shell that is launched at startup.

Lees verder Starting PowerShell as default within Windows Core

Remote manage a SQL environment with PowerShell

downloadIn this article I want to talk about managing a SQL 2012 Server with PowerShell from a remote computer. As I’ve mentioned in an earlier blog post PowerShell is becoming more and more important in the day to day task of a system administrator.

I am using PowerShell ISE as scripting application. It is a simple scripting tool but it does everything I need at this time to make my PowerShell work easy.

 

$fldr = "C:\users\robin\Documents\PowerShell\data"
$credential = Get-Credential
 
$credential.Password | ConvertFrom-SecureString | Set-Content "$fldr\adminpassword.bin"
 
$password = Get-Content "$fldr\adminpassword.bin" | ConvertTo-SecureString
 
$cred = New-Object System.Management.Automation.PSCredential("contoso\adminrobin", $password)
 
New-PSSession -Name SQL -ComputerName sql01.contoso.com -Credential $cred
 
Enter-PSSession -Name SQL

Lees verder Remote manage a SQL environment with PowerShell

Virtual Machine in VM Workstation networking conflict

Recently I upgraded my lab environment to VMware Workstation 11. After the upgrade I turned on the machines from hibernation and everything was working correctly. The next day after I rebooted all my machines all my member servers could not connect to the domain controller. Al my machines are connected trough the NAT network, and DHCP on VMware Workstation is disabled.

Lees verder Virtual Machine in VM Workstation networking conflict

Enabling Remote Desktop remotely with PowerShell

downloadLast week I was busy building a new lab environment on my Hyper-V environment. My automated installation joined the machine to my LAB environment domain and disable the Windows Firewall. The only thing I forgot to include was enabling Remote Desktop. It was not posible to start a remote registry session, and I did not have my machine running that has the Hyper-V Manager installed.
The solution is to open a remote PowerShell sessie via the ServerManager.

Lees verder Enabling Remote Desktop remotely with PowerShell

RES VDX 2014 with Citrix XenApp 6.5

res-vdx For a customer I’ve been asked to design a workstation with RES Virtual Desktop Extender (RES VDX) installed to deliver some problem applications in a proof of concept.

I am going to use RES VDX 2014 for my POC.

This customer is using Citrix XenApp 6.5 to deliver a published desktop. The user start menu is managed by the Citrix Program Neighborhood Agent. So all the start menu items are published applications.

Lees verder RES VDX 2014 with Citrix XenApp 6.5