Solved

convert member property to type int

Posted on 2014-02-20
4
305 Views
Last Modified: 2014-02-20
Hello EE,

I have a member in a system.object of typename

TypeName: System.Management.Automation.PSCustomObject

Name            MemberType   Definition                          
----            ----------   ----------                          
Equals          Method       bool Equals(System.Object obj)      
GetHashCode     Method       int GetHashCode()                  
GetType         Method       type GetType()                      
ToString        Method       string ToString()                  
name            NoteProperty System.String name=tbl_Core_Auditing
TableDataSizeMB NoteProperty System.String TableDataSizeMB=5283  

As you can see there is tabledatasizemb as type system.string , i wish to convert this to int32 for each element in the array
0
Comment
Question by:davesnb
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
you can use Int32.Parse(yourvariable.TabelDataSizeMB), this should return the int32 value for the string...
http://msdn.microsoft.com/en-us/library/system.int32.parse%28v=vs.110%29.aspx
0
 

Author Comment

by:davesnb
Comment Utility
$tblsize = import-csv C:\Scripts\dump\tblsize\$datelog.csv
$tblsize | Int32.Parse($tblsize.TableDataSizeMB)

Open in new window


Sorry not familiar with the syntax here , returns " The term 'Int32.Parse' is not recognized as the name of a cmdlet.." when using Int32.Parse($tblsize.TabelDataSizeMB)
0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
Comment Utility
If the results from Import-CSV are stored in a variable $array, you can use the following.
$array | ForEach { $_.TableDataSizeMB = [int32]$_.TableDataSizeMB }

Open in new window


Or you could just treat the property as an int32 later in your script when doing comparisons, etc.
0
 

Author Closing Comment

by:davesnb
Comment Utility
great thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now