Disabling bitlocker with PowerShell is as easy as you might not believe.
You must first unlock the drive
Unlock-BitLocker -MountPoint D:
Then you can do some object juggling to select the one you want fast using tab completion.
Something to consider, we know you can do this in the GUI, however the GUI i s point and click, where in the city of PowerShell you can use combo moves by combining cmdlets and saving on processing power, battery life and not sacrificing performance.
We all have different way to accomplish a task that is given to us. Sometimes we make mistakes and we are panicking to fix the errors better know as PowerShell error handling.
Sometimes, knowing your mistakes is better than googling or trying to the answers. I’m comfortable with PowerShell, the errors are defined in a pretty straight forward way.
The errors come out as objects with properties too and this can come in handing when you want your script to show a specific error for a certain function.
So take some time and look at cmdlets write-error and also using the cmdlet binding parameters found on built in PowerShell commands “-ErrorAction” and combining them with try, catch, and finally statements that are the dream team when it comes with error handling.
There are a number of different option regarding this and what you need, is what you should choose. try them all on and see what shoe fits.
Newer Version of PowerShell has a great deal of newer functionality and choices.
Notice how the break command drops into a debug prompt instead. This helps with Scripting and finding… bugs. so now that we have squashed that the next thing is to find was to have it help you to avoid red letters and failed automation. Share what you have done with it.
The best case scenario in my opinion of using variables is to leverage objects. I know some of the users prefer text only, but objects carry much more information, that can be logged or leveraged. Here is an example:
Having computer’s name vs and object with multiple properties.
The 3 last lines are are magic…
Having the same data in the variable and then manipulating them to give you what you want so that the data is applicable and even passed to more commands.
So lets say there is another propery or point of interest that needs to be associated with the computer and user….
Can you do that with text and then create a fancy excel sheet? maybe if you want to have panic attacks about deadlines. It is all about the objects of desire lol.
Lets add a serial number:
Lets get Dynamic like a duo (no Microsoft pun) with dynamic Data
This object is now dynamic and can be used to extrapolate data inside of a remote script, report, or function.
Brain Check… share your real world applications of create dynamic and static objects.
If you cannot think of any then use the code to inventory your home PCs. Don’t forget to add the serial number:
Don’t Forget to select the properties you need or expand them to just get the inside of the object.
Want to learn what is selectable with any object? Indicate the object and pipe it to get-member.
After reading we will try to find the module using built im module package for powershell :
we can pipe this into an “install-module” command with a few parameters to ensure a smooth install.
this should install the module and you import Excel workbooks as easily as you can excel and text files.
Import-Excel, Export-Excel with a few extra parameters like -worksheet so you can target data sets and even write reports with details on different pages!
I use this to write share permission reports with different shares on different worksheets. So other things you can do is a security audit on servers and write a server to each worksheet and then write a pivot table for a summary report.
I how you download and support this module because it is nothing short of amazing, you dont have to have the excel application installed to import or export to Excel!
One of my favorite reasons I love PowerShell is because can tap into its programming roots for added power. I will demonstrate later in my post.
Here is why:
An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25.
The base OLE Automation Date is midnight, 30 December 1899. The minimum OLE Automation date is midnight, 1 January 0100. The maximum OLE Automation Date is the same as DateTime.MaxValue, the last moment of 31 December 9999.
first there are not many reasons to convert excel to csv (who am I kidding it is tons). I ran across this issue helping a friend. I can’t believe how incredibly complicated it was to convert the time into a format that was more legible inside of the CSV file.
I think we can agree that sometimes things are harder than what they need to be and I will ensure that this can go easier specially if you take the time to make a function so that you can recall the fix in the future.
Planning is vital to any infrastructure environment and when scripting or using PowerShell is by no means any different. when you add a high level plan/structure and use it as a map of to-dos and things you want to add later and things you would like to change.
Failure to plan can mean data loss and errors that go uninvestigated. Either of which is not what you want to lay eye on or expose ears to. Error handling should go hand in hand with any PowerShell approached solution to cover your bases.
One way is to write a road map of comments in your script prior to coding. reference snippets as often as you can. enough detail so that you wont be lost of you reference that script or function 2 or 3 years from current date to create easily understood code and recycle.
Writing scripts and functions we sometimes just want something to do or be one way with one purpose.
I have mulled over things and re-coded tools to work with different things. The one thing I find to be the best in every situation is always script or code with objects in mind so that the rescuing of old code is easier.
Yeah it takes more time to do this and ensure that you aren’t reinventing the wheel.
The reality of even using PowerShell is to make your life easier. You want to ensure the process you use is refined enough to keep management at bay on your decisions and feeling confident about your solutions by reassuring them with facts and successes.
So instead of making a paper air plane that only flys in circles. Create a small engine that can fly a tiny drone and can be controlled with a strict protocol.
You may think to your self drones are cumbersome and you don’t always need to fly things but, hang on! That tiny engine can go in to a tiny car and use the same controller and so on.
I don’t want you to only be a pilot but an engineer that can reuse useful creations. Explore your horizons during down time, explore modules and other scripts to become inspired.
Take what you see and make it your foresight for newer projects. Have you taken the time to create something lately and really make it reusable?