Loading...

Follow LazyWinAdmin on Feedspot


Valid
or
Continue with Google
Continue with Facebook
LazyWinAdmin by François-xavier Cat - 3w ago
Table of content

I recently released a PowerShell module called MeetupPS. This module is a wrapper around the Rest API offered by Meetup.com. The commands available at the moment allow you to:

  • Get a Meetup group information,
  • Get Meetup events for a specific group (past and upcoming)
  • Create events

The initial reason behind the creation of this module is that I needed to gather the list of all the meetings from the last year (Title, link, attendees) and needed to submit them to the MVP Portal using the MVP Module. A long process if you do this manually.

The second reason is that I want to automate the creation of an event using something like a Plaster template (Blog post, Meetup Event, Announce to Meetup members, Skype meeting, Tweet, Slack…). This whole process is not done yet, but that would save me some times on the long term.

Install the module

Install the module from the PowerShell Gallery.

Install-Module -Name MeetupPS

Configure your connection

Follow the following steps to request a Oauth Key/Secret. Fortunately you only need to do this once.

Register a new Oauth Consumer on the Meetup API Oauth Consumer portal

  • Consumer Name Provide a name for your Oauth Consumer
  • Application Website Can be pretty much anything, here i used https://github.com/lazywinadmin/MeetupPS
  • Redirect URI Can be pretty much anything, here i used https://github.com/lazywinadmin/MeetupPS
  • Agree with terms

Once the Oauth Consumer is created, copy the Key and the Secret. This will be used to authenticate against the API

Connecting to the Meetup.com API
# Connect against Meetup.com API
$Key = '<Your Oauth Consumer Key>'
$Secret = '<Your Oauth Consumer Secret>'
Set-MeetupConfiguration -ClientID $Key -Secret $Secret

Note: This will leverage two private functions of the module:

  • Get-OauthCode
  • Get-OauthAccessToken

This will then prompt you to connect to Meetup.

Get Group information

Retrieve a Meetup group information

Get-MeetupGroup -Groupname FrenchPSUG

Get Events information

Upcoming events

Retrieve upcoming event(s) for a Meetup group

Get-MeetupEvent -Groupname FrenchPSUG -status upcoming

Past events

Retrieve past event(s) for a Meetup group

Get-MeetupEvent -GroupName FrenchPSUG -status past -page 2

Get-MeetupEvent -GroupName FrenchPSUG -status past |
Format-List -property Name,local_date,link, yes_rsvp_count

Create Event
New-MeetupEvent `
    -GroupName FrenchPSUG `
    -Title 'New Event from MeetupPS' `
    -Time '2018/06/01 3:00pm' `
    -Description "PowerShell WorkShop<br><br>In this session we'll talk about ..." `
    -PublishStatus draft

Here is the event created in Meetup

API permission scopes

The API permission scopes are set when the authentication occur in Get-OAuthAccessToken.

Currently it is requesting the following permission scopes: basic,reporting, event_management

More permission scopes are available here: https://www.meetup.com/meetup_api/auth/#oauth2-scopes

scope permission
ageless Replaces the one hour expiry time from oauth2 tokens with a limit of up to two weeks
basic Access to basic Meetup group info and creating and editing Events and RSVP’s, posting photos in version 2 API’s and below
event_management Allows the authorized application to create and make modifications to events in your Meetup groups on your behalf
group_edit Allows the authorized application to edit the settings of groups you organize on your behalf
group_content_edit Allows the authorized application to create, modify and delete group content on your behalf
group_join Allows the authorized application to join new Meetup groups on your behalf
messaging Enables Member to Member messaging (this is now deprecated)
profile_edit Allows the authorized application to edit your profile information on your behalf
reporting Allows the authorized application to block and unblock other members and submit abuse reports on your behalf
rsvp Allows the authorized application to RSVP you to events on your behalf

You can take a look a the header passed to the API here:

$Headers = @{
    'X-OAuth-Scopes'          = "basic", "reporting", "event_management"
    'X-Accepted-OAuth-Scopes' = "basic", "reporting", "event_management"
}

See this line: Header of Get-OauthAccessToken

Resources
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Table of content

In the following post I’ll describe how to add multiple contributions on the Microsoft MVP portal using the MVP PowerShell module.

You might be interested to take a look at my previous MVP PowerShell module post where I demoed how to backup all your entries into one or multiple files.

Requirements

In order to use the MVP PowerShell module, you’ll need to install it from the gallery and configure your connection to the Microsoft MVP Api webservice.

All this information is available on this post: MVP PowerShell module post

Creating one contribution entry

To create an entry you can use the New-MVPContribution function. This function comes with the following parameters:

[[-StartDate] <string>]
[[-Title] <string>]
[[-Description] <string>]
[[-ReferenceUrl] <string>]
[[-AnnualQuantity] <string>]
[[-SecondAnnualQuantity] <string>]
[[-AnnualReach] <string>]
[[-Visibility] <string>]
-ContributionTechnology <string>
-ContributionType <string>

For example we can do the following:

New-MVPContribution -StartDate '2017/09/15' `
-ContributionTechnology PowerShell `
-ContributionType 'Conference (organizer)' `
-Title 'PowerShell Saturday (Paris/September2017)' `
-Description "Full day of PowerShell :)" `
-ReferenceUrl 'https://meetup.com/FrenchPSUG/events/239169341/'

Output

ContributionId         : 810803
ContributionTypeName   : Conference (organizer)
ContributionType       : @{Id=ef6464de-179a-e411-bbc8-6c3be5a82b68; 
                         Name=Conference (organizer); EnglishName=Conference 
                         (organizer)}
ContributionTechnology : @{Id=7cc301bb-189a-e411-93f2-9cb65495d3c4; 
                         Name=PowerShell; AwardName=; AwardCategory=}
StartDate              : 2017-09-15T00:00:00
Title                  : PowerShell Saturday (Paris/September2017)
ReferenceUrl           : https://meetup.com/FrenchPSUG/events/239169341/
Visibility             : @{Id=100000000; Description=Microsoft and 
                         Contributor; LocalizeKey=}
AnnualQuantity         : 1
SecondAnnualQuantity   : 0
AnnualReach            : 0
Description            : Full day of PowerShell :)

This will create the following entry in the Microsoft MVP portal.

Now let’s look at the important parameters.

ContributionType and ContributionTechnology Parameters

The function New-MVPContribution contains two dynamic parameters for the parameters -ContributionType and -ContributionTechnology.

This means that the possible values will show as you type them.

ContributionTechnology parameter in action:

ContributionType parameter in action:

Visibility

When creating an entry you can choose who can see it. By default the value is set to Microsoft. Here are all the possible values:

  • EveryOne, (Everyone can see)
  • Microsoft, (Only Microsoft can see)
  • MVP Community, (Microsoft and MVP Community can see)
  • Microsoft Only (Seems to be similar to Microsoft)
Creating multiple contribution entries

To make the creation of your multiple entries simple, we can use Excel to build our list of contributions. Make sure you have valid ContributionType, ContributionTechnology and Visibility values, and you should be good to go.

Note that your file need to be in CSV format so PowerShell can work with it.

Example of CSV file in Excel:

Here is the sample that I’m using (You can copy and paste it into notepad and save it as a CSV file. You should then be able to open and edit it in Excel).

startdate,title,description,referenceurl,AnnualQuantity,SecondAnnualQuantity,AnnualReach,Visibility,ContributionType,ContributionTechnology
2017-12-01,Test1,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-02,Test2,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-03,Test3,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-04,Test4,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-05,Test5,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-06,Test6,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-07,Test7,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-08,Test8,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-09,Test9,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-10,Test10,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell

We can validate the file load property by using Import-CSV

Import-CSV .\Sample.csv

Creating the entries

Finally we can import all our entries by piping the entries to New-MVPContribution

# Importing multiple contributions at once
import-csv .\Examples\MultipleEntries.csv | New-MVPContribution

This should give you the following output:

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Table of content

Last year, Emin Atac and I released a PowerShell module to interact with the Microsoft MVP website, see: MVP Module.

If you are a Microsoft MVP, this module gives you quick and easy way to retrieve your entries and update your contributions.

Installing the module

The module can easily be installed from the PowerShell Gallery using the following command:

Install-module -name MVP

The first time you use the module you’ll need to complete some requirements and configure your connection, see the MVP module github page for more details.

Loading and configuring the module

After installation (and first time use requirements completed), we’ll need to load the module and authenticate against the Microsoft MVP Api

# Import the module
Import-Module -Name MVP

# Set your connection to the MVP API
$SubscriptionKey = '<Your Private Key>'
Set-MVPConfiguration -SubscriptionKey $SubscriptionKey
# This will show a Window to authenticate against Microsoft MVP API

We are now all set to use the module.

Retrieving your contributions

Retrieving all your entries can be done using Get-MVPContribution function. By default the function retrieve the last 5 entries, here is an example of output:

Get-MVPContribution
ContributionId         : 683377
ContributionTypeName   : Open Source Project(s)
ContributionType       : @{Id=414bcf30-e889-e511-8110-c4346bac0abc; Name=Open Source Project(s); 
                         EnglishName=Open Source Project(s)}
ContributionTechnology : @{Id=7cc301bb-189a-e411-93f2-9cb65495d3c4; Name=PowerShell; AwardName=; 
                         AwardCategory=}
StartDate              : 2017-02-01T08:00:00
Title                  : MVP Module
ReferenceUrl           : https://github.com/PowerShellLab/MVP
Visibility             : @{Id=100000000; Description=Microsoft; LocalizeKey=MicrosoftVisibilityText}
AnnualQuantity         : 1
SecondAnnualQuantity   : 0
AnnualReach            : 2
Description            : test
Retrieving multiple contributions

You can specify how many entries you want to retrieve using the -Limit parameter. Unfortunately at the moment there is no way to retrieve all the entries using something like -Limit 0, you need to specify a high number, example:

Get-MVPContribution -limit 1000
Backing up your contributions

Now that we have the data, we can send it to a file.

Simple backup

As an example we retrieve the last 1000 entries, convert them to a json format and save it to a file with the format BackupMVP_<yyyyMMdd_HHmmss>.json

# Retrieve 1000 contributions
Get-MVPContribution -limit 1000 |
# Convert to JSON format
ConvertTo-Json |
# Send the output to a file
Out-File -FilePath BackupMVP_$(Get-Date -format 'yyyyMMdd_HHmmss').json

This generated a file called BackupMVP_20180122_214015.json.

Backup per year

If you want to save your contributions into different files, for example per year, you can do something like this:

# Retrieve the last 1000 contributions
Get-MVPContribution -limit 1000 |
# Add a property 'Year' (we're grabing the year from the StartDate property)
Select-object -Property *,@{L='Year';E={$_.startdate.substring(0,4)}} |
# Group per year
Group-Object -Property year |
# Process each group
Foreach-object -Process {
    # Grab the current year
    $Year = $_.name
    # Get the contribution of the current group
    $ContributionsOfYear = $_.Group
    # Output the Contribution of the current year
    $ContributionsOfYear |
    # Convert to JSON Format
    ConvertTo-Json |
    # Save to file
    Out-File -FilePath BackupMVP_Year$Year-$(Get-Date -format 'yyyyMMdd_HHmmss').json
}

This generated 3 files for me:

BackupMVP_Year2015-20180122_215512.json
BackupMVP_Year2016-20180122_215512.json
BackupMVP_Year2017-20180122_215512.json

Hope you enjoyed this article !

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
LazyWinAdmin by François-xavier Cat - 6M ago
Table of content CoinMarketCap

I recently developed an interest for cryptocurrencies. It takes some time to get familiar with all the technologies involved but I’m enjoying the ride so far ::m

To follow the market, there are plenty of services and websites available. One of the most popular platform is CoinMarketCap. In addition to provide a clean interface, they offer a nice api to interact with the data of each coins.

So I figure, why not make a small PowerShell module wrapped around the coinmarketcap API.

The source of the module are available on Github here: https://github.com/lazywinadmin/CoinMarketCap

Installation

You can retrieve and install the module from the PowerShell Gallery.

# Install the module from the PowerShell Gallery
Install-Module -Name CoinMarketCap
Usage Get a Cryptocurrency information
# Retrieve Bitcoin information
Get-Coin -CoinId bitcoin

As you may know you don’t need to specify the verb Get- in powershell for most of the Cmdlets and functions declared in your sessions (Does not work with process as far as i know, probably because of the existing process {} block)

So you can simply use the following syntax

# Retrieve Bitcoin information
Coin btc

Example of output:

id                 : bitcoin
name               : Bitcoin
symbol             : BTC
rank               : 1
price_usd          : 5923.98
price_btc          : 1.0
24h_volume_usd     : 8592590000.0
market_cap_usd     : 98789398264.0
available_supply   : 16676187.0
total_supply       : 16676187.0
max_supply         : 21000000.0
percent_change_1h  : -3.27
percent_change_24h : -7.17
percent_change_7d  : -20.74
last_updated       : 1510520351
Show the Cryptocurrency web page

Many things are not available using the API, so I added a switch -Online to open the page of the CryptoCurrency you specified. This is a bit similar to Get-Help Get-Process -Online.

# Retrieve Cardano coin information
Get-Coin ada -Online

Retrieve all the existing coins
Get-CoinID

And you get the top 100

id                    name                    symbol rank
--                    ----                    ------ ----
bitcoin               Bitcoin                 BTC    1   
ethereum              Ethereum                ETH    2   
bitcoin-cash          Bitcoin Cash            BCH    3   
ripple                Ripple                  XRP    4   
litecoin              Litecoin                LTC    5   
bitcoin-gold          Bitcoin Gold            BTG    6   
dash                  Dash                    DASH   7   
iota                  IOTA                    MIOTA  8   
cardano               Cardano                 ADA    9   
monero                Monero                  XMR    10  
ethereum-classic      Ethereum Classic        ETC    11  
neo                   NEO                     NEO    12  
nem                   NEM                     XEM    13  
stellar               Stellar Lumens          XLM    14  
eos                   EOS                     EOS    15  
qtum                  Qtum                    QTUM   16  
zcash                 Zcash                   ZEC    17  
omisego               OmiseGO                 OMG    18  
lisk                  Lisk                    LSK    19  
hshare                Hshare                  HSR    20  
tether                Tether                  USDT   21  
waves                 Waves                   WAVES  22  
bitconnect            BitConnect              BCC    23  
stratis               Stratis                 STRAT  24  
populous              Populous                PPT    25  
bitshares             BitShares               BTS    26  
decred                Decred                  DCR    27  
ardor                 Ardor                   ARDR   28  
bytecoin-bcn          Bytecoin                BCN    29  
ark                   Ark                     ARK    30  
augur                 Augur                   REP    31  
komodo                Komodo                  KMD    32  
monacoin              MonaCoin                MONA   33  
steem                 Steem                   STEEM  34  
tenx                  TenX                    PAY    35  
golem-network-tokens  Golem                   GNT    36  
dogecoin              Dogecoin                DOGE   37  
maidsafecoin          MaidSafeCoin            MAID   38  
digixdao              DigixDAO                DGD    39  
pivx                  PIVX                    PIVX   40  
exchange-union        Exchange Union          XUC    41  
veritaseum            Veritaseum              VERI   42  
vertcoin              Vertcoin                VTC    43  
factom                Factom                  FCT    44  
siacoin               Siacoin                 SC     45  
salt                  SALT                    SALT   46  
power-ledger          Power Ledger            POWR   47  
nxt                   Nxt                     NXT    48  
raiden-network-token  Raiden Network Token    RDN    49  
basic-attention-token Basic Attention Token   BAT    50  
binance-coin          Binance Coin            BNB    51  
bitcoindark           BitcoinDark             BTCD   52  
gas                   Gas                     GAS    53  
byteball              Byteball Bytes          GBYTE  54  
status                Status                  SNT    55  
tron                  TRON                    TRX    56  
kyber-network         Kyber Network           KNC    57  
syscoin               Syscoin                 SYS    58  
iconomi               Iconomi                 ICN    59  
zcoin                 ZCoin                   XZC    60  
walton                Walton                  WTC    61  
metaverse             Metaverse ETP           ETP    62  
gamecredits           GameCredits             GAME   63  
aeternity             Aeternity               AE     64  
gnosis-gno            Gnosis                  GNO    65  
gxshares              GXShares                GXS    66  
bytom                 Bytom                   BTM    67  
digibyte              DigiByte                DGB    68  
ethos                 Ethos                   ETHOS  69  
blocknet              Blocknet                BLOCK  70  
civic                 Civic                   CVC    71  
funfair               FunFair                 FUN    72  
bancor                Bancor                  BNT    73  
0x                    0x                      ZRX    74  
metal                 Metal                   MTL    75  
pura                  Pura                    PURA   76  
cryptonex             Cryptonex               CNX    77  
einsteinium           Einsteinium             EMC2   78  
verge                 Verge                   XVG    79  
singulardtv           SingularDTV             SNGLS  80  
lykke                 Lykke                   LKK    81  
storj                 Storj                   STORJ  82  
minexcoin             MinexCoin               MNX    83  
zencash               ZenCash                 ZEN    84  
adx-net               AdEx                    ADX    85  
quantstamp            Quantstamp              QSP    86  
vechain               VeChain                 VEN    87  
counterparty          Counterparty            XCP    88  
ubiq                  Ubiq                    UBQ    89  
streamr-datacoin      Streamr DATAcoin        DATA   90  
substratum            Substratum              SUB    91  
aragon                Aragon                  ANT    92  
nexus                 Nexus                   NXS    93  
particl               Particl                 PART   94  
santiment             Santiment Network Token SAN    95  
bitbay                BitBay                  BAY    96  
nav-coin              NAV Coin                NAV    97  
edgeless              Edgeless                EDG    98  
monaco                Monaco                  MCO    99  
feathercoin           Feathercoin             FTC    100 
Get global market data
Get-CoinGlobal
total_market_cap_usd             : 194757913663.0
total_24h_volume_usd             : 22536410182.0
bitcoin_percentage_of_market_cap : 50.96
active_currencies                : 900
active_assets                    : 372
active_markets                   : 6513
last_updated                     : 1510520660
Get the Historical data of a currency

This one was a bit tricky. CoinMarketCap does not offer an API for that. However I noticed that when you search for set of data with a start and end date you get an url that look like this https://coinmarketcap.com/currencies/cardano/historical-data/?start=20171101&end=20171105

Finally I can easily parse the page to retrieve the table. I’m using the code from Lee Holmes.

Get-CoinHistory -Begin '20171101' -End '20171105' -CoinId ada
Date       : Nov 11, 2017
Open       : 298.59
High       : 319.45
Low        : 298.19
Close      : 314.68
Volume     : 842,301,000
Market Cap : 28,559,400,000

Date       : Nov 10, 2017
Open       : 320.67
High       : 324.72
Low        : 294.54
Close      : 299.25
Volume     : 885,986,000
Market Cap : 30,665,200,000

Date       : Nov 09, 2017
Open       : 308.64
High       : 329.45
Low        : 307.06
Close      : 320.88
Volume     : 893,250,000
Market Cap : 29,509,000,000

Date       : Nov 08, 2017
Open       : 294.27
High       : 318.70
Low        : 293.10
Close      : 309.07
Volume     : 967,956,000
Market Cap : 28,128,700,000

Date       : Nov 07, 2017
Open       : 298.57
High       : 304.84
Low        : 290.77
Close      : 294.66
Volume     : 540,766,000
Market Cap : 28,533,300,000

Date       : Nov 06, 2017
Open       : 296.43
High       : 305.42
Low        : 293.72
Close      : 298.89
Volume     : 579,359,000
Market Cap : 28,322,700,000

Date       : Nov 05, 2017
Open       : 300.04
High       : 301.37
Low        : 295.12
Close      : 296.26
Volume     : 337,658,000
Market Cap : 28,661,500,000

Date       : Nov 04, 2017
Open       : 305.48
High       : 305.48
Low        : 295.80
Close      : 300.47
Volume     : 416,479,000
Market Cap : 29,175,300,000

Date       : Nov 03, 2017
Open       : 288.50
High       : 308.31
Low        : 287.69
Close      : 305.71
Volume     : 646,340,000
Market Cap : 27,547,400,000

Date       : Nov 02, 2017
Open       : 290.73
High       : 293.91
Low        : 281.17
Close      : 287.43
Volume     : 904,901,000
Market Cap : 27,754,200,000

Date       : Nov 01, 2017
Open       : 305.76
High       : 306.40
Low        : 290.58
Close      : 291.69
Volume     : 553,864,000
Market Cap : 29,183,600,000

Let me know what you think and feel free to contribute to the module by using the issues and pull requests.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
LazyWinAdmin by François-xavier Cat - 6M ago

Table of content

Assuming the following scenario:

  • I’m declaring a module MyModule with one function called Get-Process which returns the following text: Module
  • I’m also declaring a function in my session called Get-Process which returns the following text: Function
  • And we know there is also a built-in Cmdlet called Get-Process which returns the list of processes running on my machine

If I call Get-Process which result will I see ?

Code
# MODULE
#  declare a very basic module and save to mymodule.psm1 file
@"
    function Get-Process {
        "Module"
    }

    Export-ModuleMember -Function Get-Process
"@ | Out-File mymodule.psm1 -force
#  load the module and its function
Import-Module .\mymodule.psm1


# FUNCTION
#  declare a function in my session
function Get-Process {
    "Function"
}


Calling Get-Process

Now if I run the following which output will I see ?

# Which one will be called ?
Get-Process

Output:

Function

Why ? because the function declared in my session take precedence over the module and the cmdlets.

Windows PowerShell uses the following precedence order when it runs commands:

  1. Alias
  2. Function
  3. Cmdlet
  4. Native Windows commands


Qualified name

Well what if I don’t want to change anything to my script, how can i launch the Get-Process function from the module mymodule.psm1 ?

By using the Qualified name <Module>\<function>

MyModule\Get-Process

Same if you want to call the built-in Cmdlet Get-Process, you specify the module

Microsoft.PowerShell.Management\Get-Process


What about functions ? You can’t use qualified name for functions declared in the session

Retrieving the module name

But wait, how did you know the exact module name ?

You can use Get-Command to retrieve all the Command with the name Get-Process by using the parameter -All

Get-Command Get-Process -all

Output:

CommandType  Name         Version  Source                         
-----------  ----         -------  ------                         
Function     Get-Process                                        
Cmdlet       Get-Process  3.1.0.0  Microsoft.PowerShell.Management
Function     Get-Process  0.0      mymodule                       

Then you can use -CommandType to specify the Cmdlet type and select the property ModuleName. (You’ll find also the same information in the properties Source and Module)

(get-command Get-Process -CommandType Cmdlet).ModuleName

Output:

Microsoft.PowerShell.Management


Module Prefix

One technique to prevent name conflict with module is to use Import-Module with the parameter -Prefix.

For example:

Import-Module .\mymodule.psm1 -Prefix FX

This will add FX as a prefix of all the functions noun present in the module. In our case we only have one.

Get-FXProcess

Output:

Module


More information

You’ll find more information of this topic in the following link(s)

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
LazyWinAdmin by François-xavier Cat - 6M ago

As requested by some of the attendees of my user group, here are some example on how to use $$, $^, $?

$$

Contains the last token in the last line received by the current session.

Get-ChildItem -path "c:\windows\" -filter "*.log"

$$

Returns: *.log

$^

Contains the first token in the last line received by the session.

Get-ChildItem -path "c:\windows\" -filter "*.log"

$^

Returns: Get-ChildItem

$?

Contains the execution status of the last operation. It contains TRUE if the last operation succeeded and FALSE if it failed.

Get-ChildItem -path "c:\windows\" -filter "*.log"

$?

Returns: True

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
LazyWinAdmin by François-xavier Cat - 6M ago

Someone at work was recently asking me about the following: How to remove a property from a PowerShell Object ?

Here is how you can achieve that.

Create a PowerShell Object
$MyObject = New-Object -Typename PSCustomObject -Property @{
    ComputerName = $env:ComputerName
    MacAddress = '00:11:22:33:44:55'
    Description = 'My Computer'
}

$MyObject returns:

ComputerName    Description MacAddress
------------    ----------- ----------
DESKTOP-HPHHRC5 My Computer 00:11:22:33:44:55


Remove the property
$MyObject.PSObject.properties.remove('Description')

$MyObject returns:

ComputerName    MacAddress
------------    ----------
DESKTOP-HPHHRC5 00:11:22:33:44:55
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
LazyWinAdmin by François-xavier Cat - 6M ago
Table of content

The MVP PowerShell module is finally out! This module allows you to interact with the Microsoft MVP Portal Api directly from PowerShell. The goal being to help any Microsoft MVP Award recipient to maintain and update their profile, for example by adding multiple contributions at once.

This first version is the fruit of a collaboration between Emin Atac and I.

MVP Award ?

Each year all the recipients of the Microsoft MVP Award need to submit their community contributions in order to be re-evaluated for the next nomination cycle. Until recently the only way to do so was to manually fill up each items using the Microsoft MVP Web portal.

At the beginning of 2017, Microsoft added a Rest API interface to interact with this system and help people develop their own solution to improve that process.

More information on the MVP program

MVP Module Install the module

Installing the module from the PowerShell Gallery:

# Install the module from the PowerShell Gallery
Install-Module -name MVP
Configure your connection

You need to register and get a subscription key from Microsoft in order to use the module. Fortunately you only need to do this once.

Steps

  1. Go to the Microsoft MVP API Developer Portal
  2. Click the Sign In button and sign in with your Microsoft Account. It must be the same Microsoft Account as you use for your Microsoft MVP Site access.
  3. Subscribe to the MVP Production product.
  4. Go to the PRODUCTS tab, and choose MVP Production.
  5. Click the Subscribe button.
  6. This request will be reviewed and Accepted / Declined by the admin in one or two business days. The admin verifies your access permission based on your Microsoft Account. It must be the same Microsoft Account as you use for your Microsoft MVP Site access.
  7. Once approved, on the top right corner click on your name and select PROFILE
  8. You should see a subscription for the MVP Production
  9. On the Primary Key line, select Show and this is your Subscription Key

See Getting Started with Microsoft MVP API for more information.

Next you need to configure your connection using Set-MVPConfiguration

# Configure your connection
Set-MVPConfiguration -SubscriptionKey 'abcdef083b5b482f8d99184d318b12f6'

A user interface will show to authenticate against the Microsoft API “mvpapi.portal.azure-api.net”

Commands

Here is the list of functions available in the module

# List all the functions available
Get-Command -module MVP
CommandType     Name                                               Version    Source                                                                 
-----------     ----                                               -------    ------                                                                 
Function        Get-MVPContribution                                0.0.1.0    MVP                                                                    
Function        Get-MVPContributionArea                            0.0.1.0    MVP                                                                    
Function        Get-MVPContributionType                            0.0.1.0    MVP                                                                    
Function        Get-MVPContributionVisibility                      0.0.1.0    MVP                                                                    
Function        Get-MVPOnlineIdentity                              0.0.1.0    MVP                                                                    
Function        Get-MVPProfile                                     0.0.1.0    MVP                                                                    
Function        Get-MVPProfileImage                                0.0.1.0    MVP                                                                    
Function        New-MVPContribution                                0.0.1.0    MVP                                                                    
Function        New-MVPOnlineIdentity                              0.0.1.0    MVP                                                                    
Function        Remove-MVPConfiguration                            0.0.1.0    MVP                                                                    
Function        Remove-MVPContribution                             0.0.1.0    MVP                                                                    
Function        Remove-MVPOnlineIdentity                           0.0.1.0    MVP                                                                    
Function        Set-MVPConfiguration                               0.0.1.0    MVP                                                                    
Function        Set-MVPContribution                                0.0.1.0    MVP                                                                    
Function        Set-MVPOnlineIdentity                              0.0.1.0    MVP
Retrieve a MVP Profile

You can retrieve a specific profile (your account being the default one)

# Retrieving my profile
Get-MVPProfile -ID 5000475 #Francois-Xavier Cat

Output:

Metadata             : @{PageTitle=Francois-Xavier Cat is a Microsoft MVP in PowerShell who has been in the IT field since 2007. He is currently an 
                       Automation Specialist.; TemplateName=; Keywords=; Description=}
MvpId                : 5000475
YearsAsMvp           : 4
FirstAwardYear       : 2014
AwardCategoryDisplay : Cloud and Datacenter Management
TechnicalExpertise   : 
InTheSpotlight       : False
Headline             : Francois-Xavier Cat is a Microsoft MVP in PowerShell who has been in the IT field since 2007. He is currently an Automation 
                       Specialist in a large Financial company.
Biography            : Francois-Xavier Cat is from France but has been living in Montreal, Quebec, Canada since 2004.
                       
                       In 2014, He was concurrently awarded his first MVP PowerShell by Microsoft and PowerShell Hero 2014 award by PowerShell.org. 
                       In 2015, he was also nominated Sapien Technologies MVP.
                       
                       You can follow his blog at http://lazywinadmin.com
DisplayName          : Francois-Xavier Cat
FullName             : Francois-Xavier Cat
PrimaryEmailAddress  : 
ShippingCountry      : Canada
ShippingStateCity    : Montreal, QC
Languages            : French, English
OnlineIdentities     : {@{PrivateSiteId=35435; SocialNetwork=; Url=https://www.facebook.com/fxavierc; OnlineIdentityVisibility=; 
                       ContributionCollected=False; DisplayName=; UserId=; MicrosoftAccount=; PrivacyConsentStatus=False; 
                       PrivacyConsentCheckStatus=False; PrivacyConsentCheckDate=; PrivacyConsentUnCheckDate=; Submitted=False}, 
                       @{PrivateSiteId=74042; SocialNetwork=; Url=https://www.facebook.com/lazywinadmin; OnlineIdentityVisibility=; 
                       ContributionCollected=False; DisplayName=; UserId=; MicrosoftAccount=; PrivacyConsentStatus=True; 
                       PrivacyConsentCheckStatus=False; PrivacyConsentCheckDate=; PrivacyConsentUnCheckDate=; Submitted=False}, 
                       @{PrivateSiteId=56489; SocialNetwork=; Url=http://klout.com/LazyWinAdm; OnlineIdentityVisibility=; 
                       ContributionCollected=False; DisplayName=; UserId=; MicrosoftAccount=; PrivacyConsentStatus=False; 
                       PrivacyConsentCheckStatus=False; PrivacyConsentCheckDate=; PrivacyConsentUnCheckDate=; Submitted=False}, 
                       @{PrivateSiteId=39315; SocialNetwork=; Url=http://ca.linkedin.com/in/fxcat; OnlineIdentityVisibility=; 
                       ContributionCollected=False; DisplayName=; UserId=; MicrosoftAccount=; PrivacyConsentStatus=True; 
                       PrivacyConsentCheckStatus=False; PrivacyConsentCheckDate=; PrivacyConsentUnCheckDate=; Submitted=False}...}
Certifications       : {@{PrivateSiteId=1274; Id=a2137352-509a-e431-bbc8-6c3be5a82b68; Title=VMware VCP510-DCV,; CertificationVisibility=}}
Activities           : 
CommunityAwards      : {@{PrivateSiteId=12499; Title=SAPIEN MVP; Description="SAPIEN Most Valuable Professional (MVP) award. It’s our way to 
                       recognize and show
                       our appreciation for community members who promote our products and contribute
                       to their improvement and success."; DateEarned=2015-01-16T00:00:00; 
                       ReferenceUrl=http://www.sapien.com/company/mvp/13/Francois-Xavier_Cat; AwardRecognitionVisibility=}, @{PrivateSiteId=6179; 
                       Title=PowerShell Hero; Description=; DateEarned=2014-01-08T00:00:00; 
                       ReferenceUrl=http://powershell.org/wp/2014/01/08/announcing-our-2014-powershell-heroes/; AwardRecognitionVisibility=}}
NewsHighlights       : {}
UpcomingEvent        : {}
Retrieve your contributions

You can retrieve your contributions by using Get-MVPContribution. The default limit is 5 entries.

# Retrieve your contribution
Get-MVPContribution #by default it will return 5 entries only

You can change the limit using the -Limit parameter

# Retrieve your contribution
Get-MVPContribution -Limit 100 # This will retrieve 100 entries
Create a new contribution

Creating a new contribution with New-MVPContribution requires a few fields that need to match existing data.

For example, for the Type or Technology you can use the function parameters -ContributionType and -ContributionTechnology which are Dynamic parameters to retrieve the possible values, or you can use Get-MVPContributionType and Get-MVPContributionArea to retrieve that data prior to using New-MVPContribution.

# Create splatting that will be passed
$Splatting = @{
  startdate ='2017/04/25'
  Title='Test from mvpapi.azure-api.net'
  Description = 'Description sample'
  ReferenceUrl='https://github.com/lazywinadmin/MVP'
  AnnualQuantity='1' # Need to be 1 at least
  SecondAnnualQuantity='0'
  AnnualReach = '0'
  Visibility = 'EveryOne' # Get-MVPContributionVisibility
  ContributionType = 'Blog Site Posts' # Get-MVPContributionType
  ContributionTechnology = 'PowerShell' # Get-MVPContributionArea
}

# Create a new MVP Contribution
New-MVPContribution @splatting

Output:

ContributionId         : 123456
ContributionTypeName   : Blog Site Posts
ContributionType       : @{Id=df6464de-173a-e411-cccc-6c3be5a82b68; Name=Blog Site Posts; EnglishName=Blog Site Posts}
ContributionTechnology : @{Id=7cc301bb-184a-e411-dddd-9cb65495d3c4; Name=PowerShell; AwardName=; AwardCategory=}
StartDate              : 2017-04-25T00:00:00
Title                  : Test from mvpapi.azure-api.net
ReferenceUrl           : https://github.com/lazywinadmin/MVP
Visibility             : @{Id=299600000; Description=Public; LocalizeKey=}
AnnualQuantity         : 0
SecondAnnualQuantity   : 0
AnnualReach            : 0
Description            : Description sample
Create multiple contributions

New-MVPContribution accepts values from the pipeline by property names.

For example you can provide a CSV file that look like this:

startdate,title,description,referenceurl,AnnualQuantity,SecondAnnualQuantity,AnnualReach,Visibility,ContributionType,ContributionTechnology
2017-12-01,Test1,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-02,Test2,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-03,Test3,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-04,Test4,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-05,Test5,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-06,Test6,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-07,Test7,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-08,Test8,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-09,Test9,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell
2017-12-10,Test10,Some content,https://github.com/lazywinadmin/MVP,1,0,0,EveryOne,Blog Site Posts,PowerShell

Import the CSV file and pass it to New-MVPContribution

# Importing multiple contributions at once
import-csv .\Examples\MultipleEntries.csv | New-MVPContribution
Source / Contributions

The source are available in Github MVP PowerShell module

Would love contributors, suggestions, feedback, and other help! Feel free to open an Issue ticket on the github repository.

Documentation

A more detailed documentation is available on the Github Repository in the README.md https://github.com/lazywinadmin/MVP/blob/master/README.md

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
LazyWinAdmin by François-xavier Cat - 6M ago

Table of content Introduction

La prochaine rencontre de notre groupe aura lieu le Mardi 11 Avril 2017 à partir de 19h (heure de Paris).

Cet événement aura lieu en ligne via Skype For Business (Pas de compte requis, vous pouvez rejoindre en tant qu’invité). Le lien du meeting sera envoyé aux personnes inscrites à la rencontre Meetup (voir plus bas).

Details
FrPSUG 2017/04/11
Sujet PowerShell sur Linux
Description PowerShell est maintenant Open Source et disponible pour Linux et macOS. Venez découvrir ce que cela signifie concrètement, comment installer PowerShell sur Linux et comment en profiter pleinement à travers quelques démos.
Présentateur Pascal Sauliere (Blog/Website / Twitter)
Quand 2017/04/11 19:00 (Heure de Paris)
S'inscrire Meetup
(Il est important de cliquez sur "J'y vais" / "RSVP")
Important: Le lien du meeting sera envoyé aux gens qui sont enregistré pour cette événement.
Discussion sur Slack

En tout temps nous sommes sur le channel #french sur PowerShell.slack.com (S’inscrire)

Enregistrement

La sessions sera enregistré et mise sur notre compte Youtube

Nous espérons vous voir nombreux!

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview