Tuesday, February 28, 2017

Environmental protesters leave catastrophe in their wake

Wait, what?

A total of two dogs and six puppies were found abandoned at the site and rescued by local nonprofit Furry Friends Rockin’ Rescue, local news reported on Saturday.

The two dogs the group rescued reportedly show signs of exposure to the brutal North Dakotan cold, with frost-bitten ears and mangy fur.

But, but they CARE so much!

The reports of the cast-aside canines follow news of the grave environmental threat to the Missouri River posed by the almost unfathomable amount of waste left at the site by protesters, a threat so grave it compelled North Dakota Gov. Doug Burgum to sign an emergency evacuation order.

Authorities estimated that protesters left enough garbage and human waste to fill 2,500 pickup trucks.

It sure "feels" good to make a difference, right?

Between these sorts of protesters and the Obama Admin EPA polluting that river with toxic waste, I don't know how much more help mother Earth can stand!

Tuesday, February 14, 2017

Accessing Salesforce from Powershell

I am working on a small side project at work and need to pull some account data from Salesforce to merge into a database. This has to be done with some regularity so instead of continuing to do this manually, I decided to create a Powershell script to get the data, convert it into a form that can be imported, and add that to the existing job that that runs to do other data merge tasks.

To save others some time, I am showing the basic Powershell / Salesforce script here:

# Salesforce web service access

$getUserID = Read-Host -Prompt 'Enter Salesforce user ID' # prompt for the Salesforce user
$getPassword = Read-Host -Prompt 'Enter Salesforce password' -AsSecureString # prompt for the Salesforce user password
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR( $getPassword ) # convert into form that supports decrypting
$plaintextpassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto( $BSTR ) # descrypt string so that we can sent as part of request

# issue the actual OAuth request
$url = "https://login.salesforce.com/services/oauth2/token" # OAuth URL

$params = @{ # OAuth parameters
client_id="{replace with your actual Salesforce client_id}";
client_secret="{replace with your actual Salesforce client_secret}";

# invoke OAuth call to get security token
$token = Invoke-RestMethod -Uri $url -Method Post -Body $params -ContentType "application/x-www-form-urlencoded"

#"here it is: $token"

# show that it works by getting list of available reports...
$WorkingURI = $Token.instance_url+"/services/data/v35.0/analytics/reports"
Invoke-RestMethod -URI $WorkingURI -Method GET -Headers @{ "Authorization" = "OAuth " + $Token.access_token };

# and then run a query...
$sql="select parent.name, name from account"
$WorkingURI = $Token.instance_url+"/services/data/v20.0/query/?q=$sql"
Invoke-RestMethod -URI $WorkingURI -Method GET -Headers @{ "Authorization" = "OAuth " + $Token.access_token } | ConvertTo-Json

# eof

As an added bonus, it prompts the user for their Salesforce user ID and password. This can/will have other uses. The script its self should be self-explanatory. After successful authorization, the script runs a couple of simple calls, one to retrieve a list of reports and the other to run a simple query.

It makes use of the "password" form of OAuth. You will need to configure Salesforce to allow this to work. Part of that is setting up Salesforce for REST web service access. Doing this will cause the system to generate the client_id and client_secret values that you need to pass in order to generate the token. This link will walk you through that. This script will work with a "chatter" user account as long as you set the permissions. You will need something better than a chatter account to get Salesforce configured.

Have fun...

Wednesday, February 1, 2017

A 3D Chess Grand Master

Not even two weeks into his Presidency, President Trump (has a nice ring to it, that - President Trump) has "once again" out maneuvered the entire political establishment! The guy that was a) only in it as a joke, b) has NO ability to last through the primary season, c) will quickly get bored with the rigors of the campaign trail and quit, d) is only doing this in order to build a media empire, e) can't possibly win the Republican nomination, f) will get destroyed by Hillary in the election, and g) can't possibly win as no one I know supports him, has yet again foiled the "not yet even laid" plans of the media and political establishment!

Trump Files With FEC For 2020 Election Bid, Outmaneuvers Nonprofit Organizations

Wow, just wow!

Less then two weeks in, he has already kept / made good on at least 5 of his promises to his supporters AND has completely wreaked the plans of those looking to derail his [not yet decided] reelection plans!

Note to self, buy more popcorn futures...