Solved

convert ksh commands to powershell

Posted on 2012-03-21
3
465 Views
Last Modified: 2012-06-27
Hello,

How can I convert these commands ksh to powershell ?
typeset _CKID=`echo $0 | cut -d "." -f 2`
typeset _SID=`echo $0 | cut -d "." -f 1 | awk -F "_" '{print $NF}'`

Thanks

Regards

bibi
0
Comment
Question by:bibi92
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 37751385
Hey,

I'm not too familiar with awk, I can't figure out what that one is up to without test data.

cut is just splitting and can be replaced with -split. Awk may be doing something similar so you can always split again:
$typeset_CKID = ($args[0] -split '\.')[1]
$typeset_SID = ($args[0] -split '\.')[0] -split '_'

Open in new window

Chris
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 37754521
I assume the awk line is to just get the last part of something like
   one_two_three
generated from
   one_two_three.four.five

_CKID would then be "four", and _SID should be "three".

Chris is almost there then.
$_CKID = ($args[0] -split '\.')[1]
$_SID = (($args[0] -split '\.')[0] -split '_')[-1]

Open in new window

0
 

Author Closing Comment

by:bibi92
ID: 37766466
Thanks regards bibi
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question