We should avoid using public variables in a class. In the above examples, we have used public variables for class but it is wrong to practice. 'wc.sayHiTo ("Jack") 'generates error since wc is not initialised yet In order to use the object, we need to initialize it with the "new" keyword. In delayed creation, we first declare the object only. In our example above, we have used instant creation. In Instant creation, we create an object while declaring the object with the "new" key. We use the sayHiTo method of the Welcome class to say hi to the user. This object has all the properties of the Welcome class. we run the code, Test sub creates an object wc of the Welcome class. An object is created in VBA in two methods. In sub Test, we have created is an object "wc" of Welcome class. It will prompt "Hi! Jack" on excel workbook. Wc.sayHiTo ("Jack") 'used sayHiTo method of Welcome Object. I have named my sub Test.ĭim wc As New Welcome 'Declared and initialized Welcome object Insert a new module if you don't have any. I want a function that says Hi! to the user. Now let's add a function to this class.Since I want these attributes to be available to the public, I have use accessibility operator public. Now let's create add some attributes to our class.You can change the class name from the property window. The default name is like class1, class2, and so on. The class will be added to the folder "Class module".The same thing can be done from the Insert menu. Move the cursor to Insert-> Class module. Press ALT+F11 key combination to open excel VBA editor. all are VBA classes that we use in our subs.įirst, we need to add a class module in VBA Similarly, Debug is class in VBA and print and assert are it's methods. The select is one of the functions of Range class that select the specified range. While working in VBA, you must have used Range("A1").select. You get the point.Įnough of theory, now let's see how you can use a class module in VBA. If you define a car that has 5 wheels than a car created using this class will have 5 wheels. A car object created using car class, will have all these properties. We also define what a car can do, like moving forward, backward, turn, etc. For example, a car has 4 wheels, 5 gears, steering wheel, etc. In the class, we define what the car has in it and what it can do. In real life, the model (design and functionalities) of a car is a class and the car itself is an object of that class. A class itself does nothing but using classes you can create multiple identical objects that can perform operations or can be used as a data resource. In conclusion here is how the output looks.A class is a blueprint for an object to be created. $FilePath = "C:\powershellscripts\test.csv" Get-CMApplication | Select-Object LocalizedDisplayName,SoftwareVersion,NumberOfDeployments | Export-CSV $FilePath Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' PowerShell script to list all the application deployments Launch the PowerShell and run the script.
Paste the code in the text document and rename it with filename.ps1 extension. Here we filter the output with selected objects and export the output to the specified file path.Ĭopy the below code and create a new text document. The last command is Get-CMApplication command. This is the file that contains the output. The next command is $FilePath where you define the file name and it’s path. The next command is Set-Location where you specify your site code. The path is usually “ C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1“. In addition to import the module you will have to specify the path to the Configuration Manager Module. The import-module imports Configuration Manager module into PowerShell. However you will find it difficult to understand the output because it lists many properties. However If you just type Get-CMApplication in the PowerShell, you will get a list of applications and it’s properties as output. The below script uses Get-CMApplication command to fetch the list of applications and it’s properties. List SCCM Application Deployments Using PowerShell Script You can open this output file using Microsoft Excel. The easiest way to get the list of SCCM applications is using PowerShell. You have to import the Configuration Manager PowerShell module. However if you want to get the list of apps and track the deployments, this script will help you. There might a huge list of applications that are deployed using SCCM.
The script lists the names of applications, software version and number of deployments as output. List SCCM Application Deployments Using PowerShell Script – This post is about getting the list of SCCM application deployments using PowerShell script.