Where to get PKI module for powershell - powershell

I need to get pki.psm1 file for the PKI module. Not pspki, not pkiclient, not pkitools, just pki. I need cmdlet Import-Certificate, which isn't in any of the above-mentioned modules, only in PKI. When I tried to copy the module folder from a windows 10 computer with PS 5.1, the psm1 file is missing there and the module therefore doesn't work in lower versions of PS. I need to use it in PS 2.0 if possible, since we have lots of those in our environment. Does anyone know, where can I get complete PKI module?

This Microsoft module was supplied with WMF 5.0 on Windows 10
If you look at the module details it is not compatible below Powershell 3.0:
#{
GUID="{cf094c6b-63d1-4dda-bf70-15a602c4eb2b}"
Author="Microsoft Corporation"
CompanyName="Microsoft Corporation"
Copyright="© Microsoft Corporation. All rights reserved."
ModuleVersion="1.0.0.0"
NestedModules="Microsoft.CertificateServices.PKIClient.Cmdlets"
TypesToProcess = 'pki.types.ps1xml'
HelpInfoUri="http://go.microsoft.com/fwlink/?linkid=390811"
PowerShellVersion='3.0'
CLRVersion='4.0'
CmdletsToExport = #('Add-CertificateEnrollmentPolicyServer', 'Export-Certificate', 'Export-PfxCertificate', 'Get-CertificateAutoEnrollmentPolicy', 'Get-Certificate', 'Get-CertificateNotificationTask', 'Get-CertificateEnrollmentPolicyServer', 'Get-PfxData', 'Import-Certificate', 'Import-PfxCertificate', 'New-CertificateNotificationTask', 'New-SelfSignedCertificate', 'Remove-CertificateNotificationTask', 'Remove-CertificateEnrollmentPolicyServer', 'Set-CertificateAutoEnrollmentPolicy', 'Switch-Certificate', 'Test-Certificate')
}

Related

Can't use TFS 2015 RestApi in Powershell using 'Microsoft.TeamFoundationServer.ExtendedClient' with Powershell

I'm trying to create a powershell module to interact with the new Rest Api using Powershell 3 and the assemblies from the Nuget Packages 'Microsoft.TeamFoundationServer.ExtendedClient'
15.104.0-preview 641 Monday, August 22, 2016
Some more modules are also installed from that one.
I did a basic test and after I loaded the assemblies with Add-Type i have the following assemblies loaded.
Microsoft.VisualStudio.Services.Common - 15.104.25618.0
Microsoft.VisualStudio.Services.WebApi - 15.104.25618.0
Microsoft.VisualStudio.Services.Client - 15.104.25618.0
Microsoft.TeamFoundation.Common - 15.104.25618.0
Microsoft.TeamFoundation.Client - 15.104.25618.0
Microsoft.TeamFoundation.VersionControl.Client - 15.104.25618.0
Microsoft.TeamFoundation.WorkItemTracking.Client - 15.104.25618.0
Microsoft.TeamFoundation.Build.Client - 15.104.25618.0
Microsoft.TeamFoundation.Build.Common - 15.104.25618.0
Microsoft.TeamFoundation.Build2.WebApi - 15.104.25618.0
Microsoft.TeamFoundation.DistributedTask.WebApi - 15.104.25618.0
Newtonsoft.Json - 8.0.3.19514
System.Web.Http - 5.2.20826.0
In order to load System.Web.Http I have to load Newtonsoft.Json.dll version 6.0.8
Add-Type -Path 'D:\Temp\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll'
After I loaded all the dll I tried to create a BuildHttpClien and I get an error.
$cre = New-Object -TypeName 'Microsoft.VisualStudio.Services.Common.VssCredentials' -ArgumentList (Get-Credential)
$build = New-Object -TypeName 'Microsoft.TeamFoundation.Build.WebApi.BuildHttpClient' -ArgumentList ([uri]'{TfsCollectionUrl}'),$cre
when I run this code, I got the following error
Method not found: 'Newtonsoft.Json.JsonSerializerSettings System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.get_SerializerSettings()'. (raised by: New-Object)
I tried the above code in Powershell ISE in Powershell 3.0 compatibility.
The "System.Net.Http.Formatting" and "Newtonsoft.Json" is available in Microsoft.AspNet.WebApi.Client package. To fix the error you get, you can installed this nuget package and then load these two reference from PowerShell.
Add-Type -Path 'D:\Temp\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll'
Add-Type -Path 'D:\Temp\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll'
Nuget Packages 'Microsoft.TeamFoundationServer.ExtendedClient' 15.104.0-preview is a prerelease version of Microsoft Team Foundation Server Extended Client. It's suggested to use the latest stable version 14.102.0.
Thanks to Highlight the prerelease should ne be used. It turn out it support API Call for Higher version of TFS than TFS 2015.2 (Some API call use Version 3)
I used the following Nuget Packages. Download them and Copy all the *.dll in a single folder.
id version
-- -------
Microsoft.AspNet.WebApi.Client 5.2.2
Microsoft.AspNet.WebApi.Core 5.2.2
Microsoft.IdentityModel.Clients.ActiveDirectory 2.22.302111727
Microsoft.TeamFoundationServer.Client 14.102.0
Microsoft.TeamFoundationServer.ExtendedClient 14.102.0
Microsoft.VisualStudio.Services.Client 14.102.0
Microsoft.VisualStudio.Services.InteractiveClient 14.102.0
Microsoft.WindowsAzure.ConfigurationManager 1.7.0.0
Newtonsoft.Json 6.0.8
System.IdentityModel.Tokens.Jwt 4.0.0
WindowsAzure.ServiceBus 2.5.1.0
I added the types only from some selected .dll that I put in a list and in a specific order. That seam to be a key part. NewtonSoft.Json is now in first and that work.
Name Assembly
---- --------
NewtonJson Newtonsoft.Json
IdentityModel Microsoft.IdentityModel.Clients.ActiveDirectory
VSCommon Microsoft.VisualStudio.Services.Common
VSCommonWebApi Microsoft.VisualStudio.Services.WebApi
TFCommon Microsoft.TeamFoundation.Common
TFClient Microsoft.TeamFoundation.Client
VCClient Microsoft.TeamFoundation.VersionControl.Client
WITClient Microsoft.TeamFoundation.WorkItemTracking.Client
BuildClient Microsoft.TeamFoundation.Build.Client
BuildCommon Microsoft.TeamFoundation.Build.Common
Build2 Microsoft.TeamFoundation.Build2.WebApi
DistributedTask Microsoft.TeamFoundation.DistributedTask.WebApi
After all of that, I'm able to created some basic types and start my journey into the TFS 2015 Rest web Api .
$credential = [Microsoft.VisualStudio.Services.Common.VssCredentials]::new($true)
PromptType Federated Windows Storage
---------- --------- ------- -------
PromptIfNeeded Microsoft.VisualStudio.Services.Common.WindowsCredential
$buildhttpclient = [Microsoft.TeamFoundation.Build.WebApi.BuildHttpClient]::new($tfscollectionuri,$credential)
$buildhttpclient.GetBuildsAsync('TEAMPROJECTNAME')
Result : {31221, 31220, 31219, 31218...}
Id : 165004
Exception :
Status : RanToCompletion
IsCanceled : False
IsCompleted : True
CreationOptions : None
AsyncState :
IsFaulted : False
AsyncWaitHandle : System.Threading.ManualResetEvent
CompletedSynchronously : False
Into the Result property are the builds.
NOTE: It look the Rest Api limit the number of build result to 1000's.
Still digging around to get more.

TFS Command Line not executing when output redirected

Why is the 'Resolve Conflict' window not showing when i redirect the output to a text file as shown below
d:\tfstest\tf resolve >myfile.txt
It shows when i choose not to redirect the output as follows:
d:\tfstest\tf resolve
Why is this happening????
When you use a redirect it doesn't show UI because using redirects is something you normally do in a script which chains things together. So instead the expectation is that you call tf resolve for each conflict and pass the advanced parameters to tell it how to handle these conflicts (in combination with /noprompt):
Microsoft (R) TF - Team Foundation Version Control Tool, Version
11.0.60315.1 Copyright (c) Microsoft Corporation. All rights reserved.
Resolves conflicts between changed items in your workspace and the
latest or destination versions of items on the server.
tf resolve [itemspec]
[/auto:(AutoMerge|AutoMergeForced|TakeTheirs|KeepYours|
OverwriteLocal|DeleteConflict|KeepYoursRenameTheirs)]
[/preview] [/recursive] [/newname:path] [/noprompt]
[(/overridetype:overridetype | /converttotype:converttype)]
[/properties:(#valuefile|name1=value1[;name2=value2;name3=#valuefile;
...]
[/login:username,[password]]

How to add a contributor to a TFS2010 project via PowerShell?

How do I add a contributor to a TFS2010 project via PowerShell?
Watching the powershell documentation (C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\Help\PowerShellCmdlets.mht), it looks like there is no option to add users to groups in TFS. But if you have the TFS Power Tools installed, you can use the tfssecurity tool in the command line.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>tfssecurity /?
[...]
/g+ groupIdentity memberIdentity (/collection:CollectionURI | /server:ServerURI)
Adds a user or a group to an existing group.
[...]
Identity Specifiers:
sid:sid - References the identity with the specified SID.
Example: sid:S-1-5-21-2127521184-1604012920-1887927527-588340
n:[domain\]name - References the identity with the specified name. For Windows, name is the logon name. If the referenced identity is in a domain, the domain name is required. For application groups, name is the group display name and domain is the URI or GUID of the containing project. In this context, if domain is omitted, the scope is assumed to be collection-level.
Example: To reference the identity of the user "John Peoples" in the domain "Datum1" at the fictitious company "A. Datum Corporation, you would use the following syntax:
n:DATUM1\jpeoples
Example: To reference application groups, you could use either of the following syntaxes:
n:"Full-time Employees"
n:00a10d23-7d45-4439-981b-d3b3e0b0b1ee\Vendors
[...]
So it would look like:
tfssecurity /g+ [ProjectName]\Contributor Domain\UserName /collection:http://yourTfs:8080/ProjectCollection

What is the canonical way to make autoconf link in Solaris network libraries?

On Solaris, when you compile a program that uses sockets, you need to link it with -lnsl -lsocket. Many such programs were originally written for Linux (where no extra libraries are needed), and therefore do not check for these libraries in their configure scripts, even though that is a rather simple addition. Something like this (untested):
AC_SEARCH_LIBS(gethostbyname, nsl, , AC_MSG_ERROR([gethostbyname not found]))
AC_SEARCH_LIBS(connect, socket, , AC_MSG_ERROR([connect not found]))
Is there a canonical way to do this check? Maybe even included in the autoconf distribution? You would imagine that there is a rather widespread need for that, but Google wouldn't tell me.
i think the closest to a canonical way to check this is the AX_LIB_SOCKET_NSL macro from the Autoconf Archive:
# ===========================================================================
# http://www.nongnu.org/autoconf-archive/ax_lib_socket_nsl.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_SOCKET_NSL
#
# DESCRIPTION
#
# This macro figures out what libraries are required on this platform to
# link sockets programs.
#
# The common cases are not to need any extra libraries, or to need
# -lsocket and -lnsl. We need to avoid linking with libnsl unless we need
# it, though, since on some OSes where it isn't necessary it will totally
# break networking. Unisys also includes gethostbyname() in libsocket but
# needs libnsl for socket().
#
# LICENSE
#
# Copyright (c) 2008 Russ Allbery <rra#stanford.edu>
# Copyright (c) 2008 Stepan Kasal <kasal#ucw.cz>
# Copyright (c) 2008 Warren Young <warren#etr-usa.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL])
AC_DEFUN([AX_LIB_SOCKET_NSL],
[
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket], [], [
AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
[], [-lnsl])])
])
I can't remember any finished code off the top of my head, but you usually want to check whether you can link a program calling the gethostbyname() function without any extra libs first. Only if that fails, you want to try the nsl library.
Similar things apply e.g. for the m library.

Unable to install a VSTO excel 2003 AddIn

I developped a VSTO SE Excel 2003 add in.
When launching and debuging the add in from visual studio, it works well.
But when I try to deploy it from my own install it never works.
To sum up, here is my install process:
the files are copied at the right location
I register the addin:
HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\
with the appropriate values (Default, CommandLineSage, Description, FriendlyName, LoadBehavior, Manifest).
I also add entries in
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ (with CLSID key including an UUID)
And HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
with InprocServer32 (with the manifest name and path, the addinloader.dll fullpath), ProgID (with the assembly name (without extension)), Programmable and VersionIndependententProgID (with the assembly name too).
I set the fulltrust policy to the url of every assemblies using caspol -m -ag "xxx" -url "MyUrl\Assemblies.dll" FullTrust -name "name"
Do I miss something ?
In the deployment machine, check whether the following are available:
Currect version of VSTO Runtime
Office 2003 Primary Interop Assesmblies
regards,
yenkay...
A good way to debug VSTO installation/loading issues is to have VSTO show you all errors. To do that, create an environment variable called VSTO_SUPPRESSDISPLAYALERTS with the value 0, reinstall/repair your addin, then try running Excel again.
It looks like the problem is with your registry keys. Check out the following link:
http://msdn.microsoft.com/en-us/library/bb386106.aspx
Your Software\Classes and Software\Microsoft entries should be under the same key, either HKCU or HKLM. If you have one under HKCU and the other under HKLM, it messes up the addin.
So I think the registry entry HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\ should be HKEY_LOCAL_MACHINE\Software\Microsoft\Office\Excel\Addins.
HTH...