How to upload files to Skatteverkets navet e-transport with powershell

skatteverketWhen you want to collateral an identity against the Swedish tax agency Skatteverkets service Navet one part of the process is to upload a bulk file to their service “E-transport”. In Skatteverkets technical documentation they recommend freeware program curl in windows environments, but they refer to the developer for support. The upload can easily be done with powershell and invoke-webrequest.

$produktidentitet = "xxxxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxxx"
$infil = "C:\temp\datafil.txt"

#get certificate
$certificate = Get-ChildItem -Path cert:\CurrentUser\My | where dnsnamelist -Like "*skatte*"

#Upload to Skatteverket
Invoke-WebRequest -Uri "$produktidentitet" -CertificateThumbprint $certificate.Thumbprint -Method Post -InFile $infil


Monitor solresor and notify when hotel is available

Last friday me and my girlfriend finally decided a hotel and date for the summer holiday. She had found a hotel to reasonable price at the travel-agent solresor. I told her I just had to eat and would book the trip right after lunch. When I came back the hotel was sold-out at the date we had planned for. I called the travel-agent and asked if they had any notification-service, if someone would cancel their trip, unfortunate they had no such service and they told me to check their website manually to see if the hotel would reappear. Since I am lazy and didn´t want to manually check their website a built a script to do it for me.
I found out that on step 4 in their booking the website created an unique URL with hotel short-name and departure date, if I used that URL I would get an answer with body if the hotel and date were available and I would get an empty answer if the date was sold-out.
So I made a script that checked the URL once every minute and would send me an email if the URL existed. Unfortunately the hotel never showed up, but it was fun to create the monitor.

#NAME: Checksolresor.ps1
#AUTHOR: Viktor Lindström
#COMMENTS: Check if hotel is available an a certain date

$cred = Get-Credential -Credential [user with acl to use SMTP]

while ($true)
$question = $null 
$question = Invoke-WebRequest -uri ",4&departuredate=20140609&campaigncode=&campaignnumber=&lastminute=0"
($question -eq $null)
write-host "finns inte"
{Send-MailMessage -to viktor.lindstr*m@xxxxxxxxx -Subject Resa -Body "Resa finns nu"-SmtpServer xxxxxxxxxxxxxx -From viktor.lindstr*m@xxxxxxxxxxx -Credential $cred -UseSsl
   Start-Sleep -Seconds 60