Wednesday, June 7, 2017

How to make a parameter mandatory in powershell.

How to make a parameter mandatory in powershell.

Enter this at the start of your script.

param(
            [Parameter(Mandatory=$true)]
            [string]$Server
           )

A very good explanation and additional ways to do it is here.

https://blogs.technet.microsoft.com/heyscriptingguy/2011/05/22/use-powershell-to-make-mandatory-parameters/

powershell powergui download link

Powergui is a very good powershell editor. I particularly like the speed of execution compared to windows powershell ise.



Please refer to this link for powergui and additinal downloads.

https://dmitrysotnikov.wordpress.com/2015/01/30/download-links-for-powergui-and-qad-cmdlets/

In case the page does not open the direct download link is posted below.

http://community-downloads.quest.com/powergui/Release/3.8/PowerGUI.3.8.0.129.msi

Friday, May 5, 2017

Event 4502 Log analytics customs logs not present. Unable to get blob container for CustomLog

If you get this event in your opsmgr logs.

A module of type "Microsoft.EnterpriseManagement.Mom.Modules.CloudFileUpload.CloudFileUploadWriteAction" reported an exception Microsoft.EnterpriseManagement.Mom.Modules.CloudFileUpload.FileUploadException: Unable to get blob container for CustomLog from https://omsworkspaceid.ods.opinsights.azure.com/ContainerService.svc. Will keep trying according to the specified policy. ---> System.Net.WebException: The remote name could not be resolved: 'omsworkspaceid.ods.opinsights.azure.com'
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
   at Microsoft.EnterpriseManagement.Mom.Modules.CloudFileUpload.CloudFileUploadWriteAction.GetRequestStreamCallback(IAsyncResult asynchronousResult)
   --- End of inner exception stack trace --- which was running as part of rule "Microsoft.IntelligencePacks.CustomLogUpload.UploadCustomLog" running for instance

Just make sure that you are able to infact connect to that url from your servers.
If you rule out any firewall issues and the url infact does not exist which was in my case.
Since I am running this in the Azure government cloud the url for me was different.
This url can be found out by opening the overrides pane in your scom console.
Scope it to "Health Service" and look in Management pack object rule- Target Object.
The parameter Endpoint url is an overridedable parameter. Get the right one from the overrides in the others
the values for these endpoints vary according to the services that they provide. Just pick the right one which shows up in your event.
OperationalData.svc/PostDataItems
/ContainerService.svc/PostDataItems
/EtwEventCollectionDataService.svc/PostDataItems

 Then open rules and again scope them to health service.Find your rule from the event. Check the highlighted last line  from above event.
Override this rule and add the EndpointUrl that pertains to your environment.