Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Setting up Security with Powershell

Reply
 
Old 12-18-2007   #1 (permalink)
Bakshi


 
 

Setting up Security with Powershell

Hello All,

I am writing one application to make GUI for powershell using
vb .net. Here is my basic code.


Dim myRunSpace As Runspace

Dim rsConfig As RunspaceConfiguration
rsConfig = RunspaceConfiguration.Create()
Dim snapInException As New PSSnapInException
Dim info As PSSnapInInfo
info =
rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin",
snapInException)
myRunSpace = RunspaceFactory.CreateRunspace(rsConfig)
myRunSpace.Open()

Dim cmd As Pipeline = myRunSpace.CreatePipeline()

Dim myCommand As New Command(Me.TextBox1.Text)
cmd.Commands.Add(myCommand)

Dim results As Collection(Of PSObject) = cmd.Invoke

Dim sb As New StringBuilder
Me.ListBox1.Items.Add("Command: " + Me.TextBox1.Text)
Me.ListBox1.Items.Add(" ")

For Each cmdlet As PSObject In results
Dim cmdletName As String
If cmdlet.Properties("Name") Is Nothing Then
Me.ListBox1.Items.Add(cmdlet.ToString())
Else
cmdletName =
cmdlet.Properties("Name").Value.ToString() ' & vbCrLf &
cmdlet.Properties("PSVersion").Value.ToString() & vbCrLf &
cmdlet.Properties("Description").Value.ToString()
Me.ListBox1.Items.Add(cmdletName)
Me.ListBox1.Items.Add(" ")
End If
cmdletName =
cmdlet.Properties("Name").Value.ToString() ' & vbCrLf &
cmdlet.Properties("PSVersion").Value.ToString() & vbCrLf &
cmdlet.Properties("Description").Value.ToString()
Me.ListBox1.Items.Add(cmdletName)
Me.ListBox1.Items.Add(" ")
Next



When I run any cmdlet like get-command or get-process, I am able to
get the results. I want to include all major functionality for
Exchange Server. Now here the problem comes, Whenever i am trying to
execute the Exchange Server cmdLet like New-AddressList or New-
MailBox, It gives me message saying the Term is not recognized. But
if i just write the command name like (New-AddressList), I am getting
message saying I am missing the parameter which should be supplied
with it. It makes sense that the Exchange Snap in and command is
available but some security is preventing me to run that.

Please help me.

My System SpecsSystem Spec
Old 12-18-2007   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: Setting up Security with Powershell

Quote:

> When I run any cmdlet like get-command or get-process, I am able to
> get the results. I want to include all major functionality for
> Exchange Server. Now here the problem comes, Whenever i am trying to
> execute the Exchange Server cmdLet like New-AddressList or New-
> MailBox, It gives me message saying the Term is not recognized. But
> if i just write the command name like (New-AddressList), I am getting
> message saying I am missing the parameter which should be supplied
> with it. It makes sense that the Exchange Snap in and command is
> available but some security is preventing me to run that.
>
> Please help me.
Run 'get-pssnapin' from your app to confirm that the Exchange snapin is
loaded.

Are you calling this VB.NET code from ASP.NET by any chance?

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 12-30-2007   #3 (permalink)
Bakshi


 
 

Re: Setting up Security with Powershell

Thanks Marco,

I ran that and Exchange snap in was there.

Actually the problem was in the code, when i was sending the New-
AddressList -Name "Rak****", the program was trying to parse whole "
New-AddressList -Name "Rak****" ", this as one command. while the
command is New-AddressList and -Name is the parameter to that.

So i used CommandParameter class, and it worked fine.

Yeah, I am making this application which will be available on Web
through asp .net.

Rak****
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Setting share permissions from PowerShell? PowerShell
Re: Security Setting to allow activex Vista security
Security Setting are Maddening Vista security
Re: Security Setting Vista security
Setting a WMI Namespace security descriptor with WMI/PowerShell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46