Sturbi's Home

  • Gallery
  • Modellflug
  • Datenschutz
  • Impressum

Blog

  • Allgemein (11)
    • Sprüche (6)
  • Computer (25)
    • Linux (16)
      • Nagios (5)
      • Nginx (4)
      • Postfix (3)
      • Subversion (1)
    • VMware (3)
    • Windows (9)
      • Powershell (8)
  • Fotografie (25)
  • Reise (7)
    • Hawaii (4)
    • Irland (1)
Wenn du etwas so machst,
wie du es seit zehn Jahren gemacht hast,
dann sind die Chancen groß,
daß du es falsch machst.

Charles F. Kettering amerikanischer Ingenieur * 29.08.1876, † 25.11.1958

pushalot mit Powershell

3. Januar 2015 by Sturbi Kategorie: Powershell, Windows

Da es in Powershell eine Implementation für REST gibt, muss man nicht den Umweg über den .NET WebClient gehen.

$json = @{
    AuthorizationToken = "44xx44x444x44xxxxx4xxx444x444xx";
    Body = "Body 12345....";
    Title = "Titel der Nachricht";
    Link = "https://www.google.de";
    LinkTitle = "Google";
    Source = "Powershell";
    TimeToLive = "60"
} | ConvertTo-Json

$uri = "https://pushalot.com/api/sendmessage"

Invoke-RestMethod -Method Post -Uri $uri -ContentType "application/json" -Body $json

 

Confluence mit Powershell via SOAP zugriefen

5. Januar 2014 by Sturbi Kategorie: Powershell, Windows

SOAP Dokumentation für Confluence:
https://docs.atlassian.com/atlassian-confluence/latest/com/atlassian/confluence/rpc/soap/ConfluenceSoapService.html

Webservice Objekt erstellen:

$confluence = New-WebServiceProxy -uri http://confluence.domain.tld/rpc/soap-axis/confluenceservice-v2?wsdl -namespace WebServiceProxy

Authentifizierungstoken erstellen:
$username = 'powershell'
$password = 'ak!$23Gx'
$token = $confluence.login($username,$password)

alle Spaces auflisten:
$confluence.getSpaces($token)

alle Seiten eines Spaces auflisten:
$confluence.getPages($token, "TestSpace")

eine Seite aus einem Space abrufen( hier die „Home“ Seite des Spaces):
$homepage = $confluence.getPage($token, "TestSpace", "Home")

der Content der Seite lässt sich über die Eigenschaft „content“ zugreifen:
$homepage.content

Anpassen und Speichern der Seite:
$homepage.content = "some new Text"
$confluence.storePage($token, $homepage)

Eine neue Seite erstellen und in der Linkansicht anzeigen:
$newpage = New-Object WebServiceProxy.RemotePage
$newpage.title = "Powershell Test Page"
$newpage.content = "Test with Powershell"
$newpage.space = "TestSpace"
$newpage.parentId = $homepage.id
$confluence.storePage($token, $newpage)

 

Credentials in Powershell aus KeePass laden

28. November 2013 by Sturbi Kategorie: Powershell, Windows

benötigt werden:

  • KeepPass http://keepass.com/
  • KeePassREST http://www.smartftp.com/keepassrest ( auf passende Version achten!)
  • ein Benutzerzertifikat im Windows Certificatestore z.B. von http://www.startssl.com/

Wir brauchen den Thumbprint des zu verwendenden Zertifikates:

dir cert:\CurrentUser\My

Die UUID des Eintrages aus der KeePass Datenbank

2D993D3EE140572AAC40F91804E3E383CC51BFAA

Der Code zum benutzen eines Usercertificate durch den Webclient ist von http://stackoverflow.com/questions/5621954/how-can-you-add-a-certificate-to-webclient-in-powershell

ACHTUNG:

Die Credentials stehen im Klartext in der Variable $keepasscred. Die Variable sollte so schnell wie möglich wieder gelöscht werden!

Remove-variable "keepasscred"

Zum Schluss haben wir mit $admincredentials ein Object vom Type System.Management.Automation.PSCredential

Hier der gesammte Code:

$def = @"
public class ClientCertWebClient : System.Net.WebClient
{
   System.Net.HttpWebRequest request = null;
   System.Security.Cryptography.X509Certificates.X509CertificateCollection certificates = null;

    protected override System.Net.WebRequest GetWebRequest(System.Uri address)
    {
        request = (System.Net.HttpWebRequest)base.GetWebRequest(address);
        if (certificates != null)
        {
            request.ClientCertificates.AddRange(certificates);
        }
        return request;
    }

    public void AddCerts(System.Security.Cryptography.X509Certificates.X509Certificate[] certs)
    {
        if (certificates == null)
        {
            certificates = new System.Security.Cryptography.X509Certificates.X509CertificateCollection();
        }
        if (request != null)
        {
            request.ClientCertificates.AddRange(certs);
        }
        certificates.AddRange(certs);
    }
}
"@

Add-Type -TypeDefinition $def

$wc = New-Object ClientCertWebClient
$certs = dir cert:\CurrentUser\My | ?{$_.Thumbprint -eq "2D993D3EE140572AAC40F91804E3E383CC51BFAA"}
$wc.AddCerts($certs)
$keepasscred = $wc.DownloadString("https://localhost:12984/keepass/entry/70B660CF23658D4C8F24B60B17017372") | ConvertFrom-Json

$username = $keepasscred.Username
$password = $keepasscred.Password
$admincredentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))

# remove all temporary variables with Cleartextpasswords!
Remove-Variable "keepasscred"
Remove-Variable "username"
Remove-Variable "password"

 

VMware Certificate Automatation Tool Pitfalls

30. Juli 2013 by Sturbi Kategorie: VMware

I guess, these errors are specific to german installation of vSphere 5.1U1a

first error: the username

No mather what the example in the ssl-environment.bat say, usernames are EVER written like „admin@system-Domain“  and „administrator@domain.local“. Names like „DOMAIN\User“ will not work and produce strange authentication errors.

second error: „Cannot reload the vCenter Server SSL certificates. The certificate might not be unique.“

I wonder how this error can raise on a fresh server, installed with „Simple Install“ (Build 1064983) and certificate requests generate by the script.
After hours of surfing the Web, I found this: http://communities.vmware.com/thread/446747?start=0&tstart=0

Open C:\ProgramData\VMware\VMware VirtualCenter\LS_ServiceID.prop and copy the line to clipboard.
Open C:\ProgramData\VMware\VMware VirtualCenter\vpxd.cfg and search for the line containing „<serviceId>vCenterService</serviceId>“ (line 50 on my file)
Replace „vCenterService“ with the GUID from clipboard like „{16B7163E-CCEA-47E3-891E-B2BFEEBEEB1F}:5“ (note the number at the end not missing „:5“ !)
Close and restart vCenter Service (can take up to 10 minutes to finish)

Now You should be abble to replace the vCenter Server Certificate.

Gänseklein

3. Juni 2013 by Sturbi Kategorie: Fotografie

Nachdem ich sie 2 mal abends beim Sonnenbad gesehen hatte, bin ich nochmal schnell mit der Kamera hingefahren. Etwas zu spät abends und zu weit weg. Aber sie können mir nicht entkommen, das Wasserwerksgelände ist gut eingezäunt 😉

6832

Die Hummel

1. Februar 2013 by Sturbi Kategorie: Sprüche

Aussage:

Die Hummel hat ein Gewicht von 1,2 Gramm bei einer Flügelfläche von 0,7 cm2.
Nach den Gesetzen der Aerodynamik kann die Hummel nicht fliegen.
Die Hummel weiß das nicht, die fliegt einfach.

Ableitungen:

bringe der Hummel Aerodynamik bei und sie stürzt ab.

So lange du nicht weißt was du tust, glaubst du, du kannst fliegen.

Piloten wissen nicht, was sie tun, denn sie fliegen.

Wer nicht weiß was er tut, ist dick, schwarz-gelb und brummt.

  • « Vorherige Seite
  • 1
  • …
  • 3
  • 4
  • 5
  • 6
  • 7
  • …
  • 10
  • Nächste Seite »

© 2022 · Sturbi's Home