Tag Archives: powershell

Powershell Script for emailing PPCoin price on Vircurex

I have recently found myself checking the price of PPCoin on a daily basis. Obviously this sort of thing can be automated with a script, so here it is. Powershell was brought into service for this one: I haven’t got much experience with Powershell so had to google my way around, and learnt something in the process.

The Powershell Script

$url = "https://vircurex.com/api/get_info_for_currency.xml"
$xml = [xml](new-object system.net.webclient).downloadstring($url)
$from = "***@***.com"
$to = "***@***.com"
$subject = "PPC"
$server = "servername"
$smtp=new-object Net.Mail.SmtpClient($server)
$smtp.Send($from, $to, $subject,$xml.hash.PPC.BTC."highest-bid".get_InnerXml())

Obviously you’ll need to set the from and to addresses, and the servername correctly for your environment. Also, as I am using this on a domain joined PC, it uses the default credentials so I didn’t need to set any on the SmtpClient. I’m sure the above script could be improved so that you pass the to address in via an argument, but this is a quick and dirty hack so it doesn’t really matter. However, it definitely would benefit from some exception handling…

Scheduling the Script

I then saved this script and scheduled in Windows using the Task Scheduler. I had to use the full path of the 32-bit Powershell executable (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe on my Windows 7 box), and used -Command “D:\PPC.ps1”  for the arguments (where D:\PPC.ps1 is the full path of the script):

Powershell Scheduled Task

And there you go! Powershell to the rescue.

As a sidenote, I have had issues sending emails when using the SmtpClient in .NET and a domain-joined PC & user. If you’re getting a ‘Client does not have permissions to send as this sender‘ exception, then you need to ensure that the user ‘NT AUTHORITY\SELF’ has ‘Send-as’ permissions on the user in question. The following link helped me out with this issue:



Swyx: IpPbx PowerShell – Creating new phonebook entry

The following script will create a new phonebook entry in Swyx. You’ll need the IpPbx PowerShell modules installed first. Oh, and be sure to replace [servername] with, well, the name of your server.

Import-Module IpPbx
Connect-IpPbx [servername]
New-IpPbxPhonebookEntry -Name "NAMEHERE" -Number "NUMBERHEREWITHPAPREFIX" -Description "POWERSHELL IMPORT" | Add-IpPbxPhonebookEntry

Swyx PowerShell: IpPbx Modules – Installation

Swyx PowerShell

Before you can use the IpPbx cmdlets in PowerShell, you need to install the modules first. Grab the IpPbx modules from here, be sure to get the correct version:


Don’t forget to run the following command first:

Set-ExecutionPolicy unrestricted


[quads id=1]

As our ‘My Documents’ folder live on the domain server, we had some issues. The install appeared to go ok, as you can see:

1. Install for Current User only
2. Install for All Users
3. Remove every module version
Select 1-3: 1
Searching for other Module Versions...
Installing for Current User...
Process completed!
Press any key to continue ...

Do not do the above! Because you then get this:

PS C:\Users\xxx\Desktop\IpPbxPowerShellModule_v8.1.0.50 (1)> Import-Module IpPbx
 Add-Type : Could not load file or assembly 'IpPbxBLOB64, Version=, Culture=neutral, PublicKeyToken=null' or one
 of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
 At \\xxx\Users\xxx\WindowsPowerShell\Modules\IpPbx\IpPbx.psm1:106 char:13
 + add-type <<<< -Path (join-path $ScriptFolder "Binaries\IpPbxBlob64.dll") | out-null 
 + CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
 + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

This is because it installed the modules in the folder on the server, and network paths are not trusted.

Instead, install for all users – option 2 (you need to run the PowerShell command prompt as Administrator).

To check the install, run the following command:

get-module -ListAvailable

The result list must contains the following entries:

Script Accelerators
 Manifest IpPbx

If it does, then all should be well.

For more information on Swyx telephony & the Swyx Powershell modules, please check out the following link:



Check out my other posts regarding Swyx here: