I am trying to create a programma that gathers system data like CPU name and speed and Physical Memory things like that
i succeeded in loading the data i use:
Dim searcher As ManagementObjectSearcher = _
New ManagementObjectSearcher("select * from Win32_Processor")
For Each oReturn As ManagementObject In searcher.Get()
Im trying to create an app that will do some funky things with new users/leaving users and apply a load of business requirements around this. After playing about with Powershell forms, ive decided to embedd powershell within a VB.net app.I am using the following code, which is always returning "Nothing", as in no result, which is causing me a real headache. The same code works with Get-QADuser, and Get-Command, just not Get-Mailbox.I will also need to call New-Mailbox and othe commands later on in the proces.
I need to call Powershell commands via my code and I find at least 2 different examples of doing this. I'm wondering what the differences between the methods are and why I would use one as opposed to the other.The first (simpler?) method goes something like this:
[code]...
I also know that with either method I can pipe the command to out-string to make Powershell return strings instead of objects.My question is, which method should I use and why? They both seem the same to me.
I have a file full of last-names separated by commas and then first-names.
Smith,Bob Chicken,Ronald Car,Anastasia
Code: gc permissions.csv|% {$_.split(",")[0]}
I'd like to grab the first character of the first name and then pre-pend it to the string of the last name. The general idea is to find the user ID that's stored in Active Directory, in my company it's the first letter of the first name and then the last name.
Then I'm trying to add these users as read-only on a specific directory.
Running the following code resulting in an HostException;
Public Sub RunPowershellInConsole(ByVal scriptText As String) Dim config = RunspaceConfiguration.Create Dim args() As String = New String() {scriptText}
I took the dive into learning VBScript due to some server side scripts that I work with. During a course I ran into Powershell and did some Google searching. From what I was reading, VBScript is good for legacy applications and Powershell is the way to go for Win7. I did not run into anything telling me of this being true or if its a false statement and VBScript will be used for Win7 and Win8. Should I look into learning Powershell and abort my VBScript for now and just worry about VBScript for legacy systems?
I'm evaluating the best approach to implement the following periodic task:
Get some users from SQL Server (2008) and then for each user enable licences in the Cloud (Office 365) using PowerShell.
My first thought was a console-based app in C# or VB.net but now that I realize that running a PS Script remotely using C# can be quite a challenge I'm starting to think in alternatives like perform all the stuff using PowerShell, I guess this is a better approach but I'd like to hear your thoughts on this.
We use VB2005, Along with Powershell to manage our exchange infrastructure. VB.Net codes have been compiled to support MIIS2003 Operations. One of the operations require the functions in VB.net to write an output into .csv file. This file receives jibberish characters as input after the functions are executed.
I have to call PS commands from a VB.NET program. This works fine if I'm calling standard PS commands, but if I have to call a command that lives in a 3rd party module I can't seem to make it work. At the PS console I can type Import-Module MyModule and then I can call the commands in that module. I tried the following but it doesn't work, I still can't access my command from within the module:
Dim PowerShell As Management.Automation.PowerShell = PowerShell.Create() Dim PowerShellCommand As New PSCommand() Dim PowerShellCommandResults As Object
I have a Powershell script and no matter what I try it completly ignores any quotation marks in the script. The error occurs when I run the script from my VB.NET code yet, I have been running scripts sucessfully through VB.NET for a while now. For example, my script starts with finding out the server name...
I currently have an ASP.NET programming creating a Powershell CmdLet to create a mailbox in exchange. The issue I'm having is sometimes is fails to create the mailbox because "it can't find" the exchange database I am specifying. So what I'm trying to do is run a Get-Mailbox and then pipe the results to an Enable-Mailbox command. Below is the code I am using to do it:
I'm currently having issues calling a .ps1 file in my vb.net project. The program is supposed to provide a simple way for end users to unlock Active Directory accounts. The vb.net project is simply a text box with a button. Users will type the username of the locked account. When the button is pressed, the program writes whatever is in the text box into a CSV file. The CSV file has a samAccountName column in it. After the file is written to, the program then calls a Powershell script that reads the CSV file and unlocks the account based upon what is in the file.The program does everything it is supposed to except for calling the Powershell script to actually unlock the account. I've tried a Process.Start(filePath) which would open the file, but opened in notepad and didn't execute anything. Right now the program is calling a batch file which is supposed to run the script in Powershell but that attempt also failed.
I'd like to start off by saying I'm not really a programmer just a sysadmin who likes to dabble (so simple answers would be nice ;) ),I've created a webapp that's used by some less technical folk to do basic administration tasks(User provisioning through our IDM, Updating passwords, Disabling accounts, Editing user details, etc)there's also a couple of exchange functions that are currently handled by exporting a CSV that a separate powershell script processes.I'm trying to bring these powershell functions into the application to reduce complexity but I'm having some trouble.
When I execute the "Add-MailboxPermission" command I get no return output (nor does it apply the change) at all, unless I put no parameters,in which case it throws the expected missing parameters exception (Not scientific but proves it's loading the exchange plugin fine and executing):
private sub cmdMbxFullAccess(sender as object, e as eventargs) Dim psRunSpaceConf As RunspaceConfiguration = RunspaceConfiguration.Create() Dim psConfException As PSSnapInException[code].....
If however I issue a simpler command like "Get-Host | Out-String" I get return output as expected. Thus far I have checked that the user context it's running under has the correct permissions and tried executing the command from the powershell prompt on that server to make sure that there isn't some other external issue I am overlooking.how I can further debug this, it's like the command disappears into the ether never to be heard from again!
I'd like to start off by saying I'm not really a programmer just a sysadmin who likes to dabble (so simple answers would be nice ;) ), I've created a webapp that's used by some less technical folk to do basic administration tasks (User provisioning through our IDM, Updating passwords, Disabling accounts, Editing user details, etc) there's also a couple of exchange functions that are currently handled by exporting a CSV that a separate powershell script processes. I'm trying to bring these powershell functions into the application to reduce complexity but I'm having some trouble.
When I execute the "Add-MailboxPermission" command I get no return output (nor does it apply the change) at all, unless I put no parameters, in which case it throws the expected missing parameters exception (Not scientific but proves it's loading the exchange plugin fine and trying to execute):
I wonder if it is possible to write and capture errors when running a script to PowerShell.In my case I am using the following code:[code]' add an extra command to transform the script output objects into nicely formatted strings' remove this line to get the actual objects that the script returns, for example, see the script "Get-Process" returns a collection.[code]
I followed Ziannb article on involking powershell from visual basic. It works great but it doesnt allow me to run scripts with [URL]
- how can i run powershell scripts with arguments from VB
- how can i run one powershell command line at a time from VB. When i use below two command, it pipes the first command to the second one..instead of running them individually :
I am trying to run powershell script from VB and I want to see the output of the script as it is running inside a console application. With my script (shown below) when I run from powershell it shows "Command Sleep Starting" and then waits for 5 seconds and then displays the other text.
However, when I run from VB.NET program, the execution waits for 5 seconds and dumps all the text output at once. It doesn't execute first Write-Output command and then wait and then output as it should.[code]...
If Class X is within the scope of Class Y, is X a subclass of Y?If Class A is a sub Class of B, then is Class B considered a super class of A?if Class C inherits Class D is Class D a superclass or parent of Class C?if Class E extends Class F then we can consider Class E a child of F?if Class G inherits Class H and is within the scope of Class I then who is the parent of Class G? Classes that inherits Class J and classes that are within Class J are all sub classes of Class J?
I have put this code in the global form Inherits System.Windows.Forms.Form. And then in the form that will inherit this from the global Inherits MenuStrip. "MenuStrip" is what the global form is called. But keep getting this error: Error1Base class 'MenuStrip' specified for class 'Lesson2' cannot be different from the base class 'System.Windows.Forms.Form' of one of its other partial types.
It is in the file ClientProfile I have placed in both App_Code and also App_Code/Models
In my code behind I have the following
[CODE]...
The last word, "ClientProfile" has the scary squiggly red line below it. It is not recognizing my class.Even the Intellisense is not picking up te class. Do I have to register the class file in any way?
Dim a as Type=GetType(className) would gimme the type. But I have only the name of the class as string. I want something like GetType("class1") which would return the type.
so I used to mess around with C#, just a little. And someone had helped me make a class for Visual C# that was supposed to do the math parts for "internal structure" - which the program used for a part of its calculations and screen... Basically there were 2 options. Endo-Steel and Standard. The user would use a updownbox to determine weight of the machine and then internal structure was a % of that total. If it was standard then it was 10% of the overall weight, if it was Endo-Steel then it was 50% of standard (so 5% of total weight) rounded to next 0.5 (so .25 was .5, 1.25 was 1.5, 1.75 was 2.0, etc). I have the code for the C# class file for it, but want to make it in VB.
I need to create unit testing project for my current website. The currentw ebsite si written in VB. All unit testing examples are using interface to create mock object. My current VB class does not implment any interface. Can I add interface and implement it to my current class and functions without affecting or changing codes to any pages in my website that call the functions? For examples my current class is like:
I've been creating short test apps repeatedly to try to understand some of the concepts in VB.NET.For the most part it has been illuminating.I read Bucky's .NET knowlegebase tutorial on passing objects as parameters to newly created forms. He shows how to create a new class that inherits from the base form class and define a New() method with parameters Extending the concept I thought about doing the same thing with a form that was created at design-time (In this case Form2).
Imports System.Threading Public Class TestClass Private myClassThread As New Thread(AddressOf StartMyClassThread)
[code]....
The result:Application runs, no errors or exceptions.Displayed is the listbox and the Start button.I press the start button and a msgbox says "Not Invoked" as expected and upon clicking OK to that msgbox "Start Button Pressed" is added to the Output listbox control.Immediately following that the msgbox pops up again and says "Not Invoked". I was expecting "Invoked" as a separate thread is trying to use the Output listbox control.Of course this results in the Output.Items.Add being attempted which results in no visible result as the thread is not allowed to directly update the UI control.