Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

Powershell script for SCCM 2012 using windows 2008r2 task scheduler

$
0
0

Hi,

I have a powershell script which i run against my SCCM 2012 console server to extract information.

The script, imports the required SCCM 2012 module and then does its task. It works fine if i run it normally in a window. But when i try and run it using task scheduler, it completes in about 2 or 3 seconds without actually doing anything.

Is there anyway, i can get task scheduler to open the powershell window to see why and when the task fails?

Or has anyone seen a similar issue when attempting to import a module during a scheduled task?

Thanks in advance


User update script using XML File

$
0
0

Hi,

I am basically trying to update AD users from xml file.

I compare user names with email initials and if it contains that users some fields i am updating else i create new user.

But If condition is not working and directly trying to create new user.

If you can help me i will be so glad.

thanks, 

$path_to_users_xml = "C:\veracross\facstaff.xml"
$text = Get-Content   $path_to_users_xml                          #importing xml
$text  -replace (' type="integer"'), ''| Out-File $path_to_users_xml #removeing ' type="integer and rewriting file
$text = Get-Content   $path_to_users_xml
$text  -replace (' type="date"'), '' | Out-File $path_to_users_xml #removeing ' type="integer and rewriting file
$text = Get-Content   $path_to_users_xml
$text  -replace (' display="false"'), '' | Out-File $path_to_users_xml #removeing ' type="integer and rewriting file
$text = Get-Content   $path_to_users_xml
$text  -replace (' display="True"'), '' | Out-File $path_to_users_xml #removeing ' type="integer and rewriting file
$text = Get-Content   $path_to_users_xml
$text  -replace (' type="boolean"'), '' | Out-File $path_to_users_xml #removeing ' type="integer and rewriting file
$text = Get-Content   $path_to_users_xml
$text  -replace (' type="datetime"'), '' | Out-File $path_to_users_xml #removeing ' type="integer and rewriting file
$text = Get-Content   $path_to_users_xml
$text  -replace (' type="array"'), '' | Out-File $path_to_users_xml #removeing ' type="integer and rewriting file
$text = Get-Content   $path_to_users_xml                          #importing xml
$text  -replace ('<biography/>'), '<biography>X</biography>'| Out-File $path_to_users_xml #removeing ' type="integer and rewriting file
#$text = Get-Content   $path_to_users_xml                          #importing xml
#$text  -replace ('<biography>X</biography>'), '<biography>XX</biography>'| Out-File $path_to_users_xml #removeing ' type="integer and rewriting file


$Dataxml = [Xml] (Get-Content $path_to_users_xml)
 $Datas =  $Dataxml.facstaff.facstaff

 $members = Get-ADUser -filter *  -SearchBase "OU=Staff,OU=Psi,DC=Psi,DC=kiev,DC=ua" | FT name #| Select-Object -ExpandProperty name
 #Get-ADUser -filter *  -SearchBase "OU=Other Staff,OU=Psi,DC=Psi,DC=kiev,DC=ua" | Select-Object -ExpandProperty name | ForEach-Object{ $members += $_ }
 $members




 foreach ($facstaff in $Datas )
  {
    $OU = "ou=Staff,ou=psi,dc=psi,dc=kiev,dc=ua"  <#Если каталог с таким именем не найден отправляем в OU other#>
    $login = [string] $facstaff.email_1
    $login =  $login.replace("@psi.kiev.ua", "")
    $loginx = ('CN='+$login+',ou=Staff,ou=psi,dc=psi,dc=kiev,dc=ua')
    $UserLastName = $facstaff.last_name
    $UserFirstName = $facstaff.first_name
    $Detailedname = ($UserFirstName+' '+$UserLastName)

    $hash= @{

  Company = $facstaff.faculty_type
  Title = $facstaff.job_title
  vdepartment = $facstaff.department
  vbiography = $facstaff.biography
  vrole = $facstaff.roles
  vSchoolLevel = $facstaff.School_Level
  vupdatedate = $facstaff.update_date

 }



 If ($members.name -Contains $login)

 {
  Get-ADUser  -filter { SAMAccountName -like $login } -SearchScope Subtree -SearchBase "OU=Psi,DC=Psi,DC=kiev,DC=ua" |  move-adobject -TargetPath $OU
  Get-ADUser  -filter { SAMAccountName -like $login } -SearchBase "OU=Staff,ou=psi,DC=psi,DC=kiev,DC=ua" -properties Company,Title,vdepartment,vbiography,vrole,vschoollevel,vupdatedate
  Set-ADUser $login -Replace $hash
  Write-Host "Active Directory user named $login updated."

 }

 Else

 {

   Write-Host "Active Directory doesn't contain user named $login . User created."
   New-ADUser -Name $login -SamAccountName $Login -UserPrincipalName $login  -AccountPassword  (ConvertTo-SecureString -AsPlainText "Psi12345" -Force) -Company $facstaff.faculty_type -Title $facstaff.job_title  -DisplayName $Detailedname -Department $facstaff.department -EmailAddress $facstaff.email_1  -GivenName $facstaff.first_name  -Enabled $true -Path $OU  -Surname $facstaff.last_name -OtherAttributes @{"vgender"=$facstaff.gender; "vbiography"=$facstaff.biography; "vrole"=$facstaff.roles; "vpersonid"=$facstaff.person_pk; "vSchoolLevel"=$facstaff.School_Level; "vupdatedate"=$facstaff.update_date; }

}


}


Mount-VHD does not affect a drive letter to the mounted partition

$
0
0

Hi

Mount-VHD does not affect a drive letter to the mounted partition :

PS C:\Windows\system32> Mount-VHD -Path "d:\vhdx\winnie.vhdx" -ErrorAction SilentlyContinue -PassThru | Get-Disk | Get-Partition   Disk Number : 2

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
1                                                  1048576                                      20 GB IFS

Windows HyperV 2012 R2

This worked previously....

Any suggestion ?

Thanks.

David.

Add blank column to csv with no header?

$
0
0

My business requirement is to create a formatted file that will be used to import user id's.

I am using a slightly modified script provided by johan13, and I am stripping the headers.

I need to add a blank column between CN and DisplayName so that my input scripts will read the file contents correctly.
I've been searching and have found some hints on how to do this but nothing that does not include headers and so far my tests have not worked.   

import-module ActiveDirectory

$ADUserParams=@{
'Server' = 'oooo.xxx'
'Searchbase' = 'ou=x00x,ou=accounts,dc=oooo,dc=xxx'
'Searchscope'= 'Subtree'
'Filter' = '*'
'Properties' = '*'
}

#This is where to change if different properties are required.
$SelectParams=@{
'Property' = 'CN' , 'DisplayName', 'EmailAddress'
}

get-aduser @ADUserParams | select-object @SelectParams |

ConvertTo-CSV -notype | Select-Object -skip 1 |
ForEach-Object { $_ -replace '"',""} |
out-file "C:\temp\users2.csv" -force -Encoding Ascii


Windows DHCP add DNS Suffixes, Option 119

$
0
0

Hi, in Windows DHCP i need to add a DNS suffix (option 119), but it seems that it only accepts values in Decimal or Hexadecimal

If i want to add the suffixes

 'mycomp.com','comp.mycomp.com'

I will need to convert this to decimal or Hex first..

function Create-ValidDNSSearchListHex ($Strings){
  foreach ($String in $Strings){
    foreach ($Part in $String.split('.')){
        $R += "0x{0:X2}," -f ($Part.Length)
$ans = ''
[System.Text.Encoding]::ASCII.GetBytes($Part) | % { $ans += "0x{0:X2}," -f $_ }
$R += $ans
    }
    $R += "0x00,"
  }
  $R.Trim(' ',',')
}

Then i use the fubction to convert my strings

$sfx =Create-ValidDNSSearchListHex  'mycomp.com','comp.mycomp.com'

And when i try to add the option it fails

Set-DhcpServerv4OptionValue -scopeid 10.25.55.0 -OptionId 119 -Value $sfx

error:

Set-DhcpServerv4OptionValue : Parameters for option value to be set for option ID 119 do not match with option definition on DHCP server DHCPserver-01.
At line:1 char:1

Any ideas how can i fix this?

Thanks

Avoid GUI freezing

$
0
0

I need help on Powershell GUI interface. On long last processes/loops GUI is freezing and I want to avoid that. I want to refresh GUI (richtextbox value) on backgroud or from different runspace.

I do not think that background job is a solution. Maybe a hastable and different runspace.

He is my code about this issue. Can anyone give me a better example or edit my code?

Copy code and save as .ps1

********** CODE ***************

#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: 2a715e2e-26db-488f-ab65-742aaad00d98
# Source File: GUIrefresh.psf
#------------------------------------------------------------------------
#region File Recovery Data (DO NOT MODIFY)
<#RecoveryData:
UQoAAB+LCAAAAAAABAC9Vl1v2jAUfZ+0/2DlOQJCPigSRCrZOlXrtqrQbm/ISW7Aw7GR7bRkv37O
B4yWFtKuoEhRjI997rnnxGFwAxG/B5F/wgoj/SAJZ0Oja/gfPyA0+CHIjDBMLwiF7zgF/8vtpYBE
gJy3ljIZtHcA1bLwN0QKqXwJQ2OcSwVp6ydhMX+QrQsu0upuouemTHRXV+G0OsVloiCjKhMwZJAp
gamJrrOQkugr5BO+ADYMez3sRq5n9W0HOmd9AzFdytBI9H6WgaI5obHQOCPgTAlOZaVOF3ot+BKE
yusFASXA1Jj8AcN3PM9EjucO2mvQC4sK2YZfch3ETmClDL/QuQv9fK+5a9wVx3G957R4HrTL2TX0
cH9HmVKcHb3DYUmzt8e7TbjiEVaa3vCtrolsq7fTi5eaXNM1wFce9lwTde0G8AkOL1kMK11SE3Tp
YvNibiXcEZlhOlY5hRGOFgGnXBj+RGTw3PrtKOhMRosN27QcPolDu8pD83TckGheiBjx1dEjIjSX
0lwhX/1XTqxu45hsUzbOiuNokm6/86q0NEKXadnMHrC7QAdzzGYQPxYy3ZrZ4//jwbmUkGqbQK6x
9S+5X9v+DTM8g1Tv1jrPFE/Ljv+z325qv22FiX3meji2PQdsfWxumJ4ypzLigpLwHUK2h6XSdwqO
d391DjMWX+vTEAn8QNjsLVwdO3GTXmJZsdvBNj7M9Sulp9FEhH5BuMjHIO5JBG+y7NXqAi7gJPJq
VfqY0dKOoG0zrE6VQXv7L6T/F10qjVRRCgAA#>
#endregion

<#
    .NOTES
    --------------------------------------------------------------------------------
     Code generated by:  SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.82
     Generated on:       23.3.2015 14:19
     Generated by:       Administrator
     Organization:       W12
    --------------------------------------------------------------------------------
    .DESCRIPTION
        GUI script generated by PowerShell Studio 2015
#>
#----------------------------------------------
#region Application Functions
#----------------------------------------------

#endregion Application Functions

#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Call-GUIrefresh_psf {

 #----------------------------------------------
 #region Import the Assemblies
 #----------------------------------------------
 [void][reflection.assembly]::Load('mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
 [void][reflection.assembly]::Load('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
 [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
 [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
 [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
 [void][reflection.assembly]::Load('System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
 [void][reflection.assembly]::Load('System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
 [void][reflection.assembly]::Load('System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
 [void][reflection.assembly]::Load('System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
 #endregion Import Assemblies

 #----------------------------------------------
 #region Generated Form Objects
 #----------------------------------------------
 [System.Windows.Forms.Application]::EnableVisualStyles()
 $form1 = New-Object 'System.Windows.Forms.Form'
 $button1 = New-Object 'System.Windows.Forms.Button'
 $richtextbox1 = New-Object 'System.Windows.Forms.RichTextBox'
 $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
 #endregion Generated Form Objects

 #----------------------------------------------
 # User Generated Script
 #----------------------------------------------
 
 $form1_Load={
 }
 
 $richtextbox1_TextChanged = {
  $richtextbox1.Update()
 }
 
 $button1_Click = {
  
  # Variables
  $richtextbox1.Text = @()
  
  # Map an existing hash table to a syncronized variable for use between threads
  $ADHashTable = [HashTable]::Synchronized(@{ })
  $ADHashTable.tmptxt = "Alfa"
  
  # First value
  $tmp = "First line" + "`n"
  $richtextbox1.AppendText($tmp)
  
  # Create a new RunSpace
  $ADRunSpace = [RunSpaceFactory]::CreateRunSpace()
  $ADRunSpace.ApartmentState = "STA"
  $ADRunSpace.ThreadOptions = "ReuseThread"
  $ADRunSpace.Open()
  
  # Set Synchronized hash table variable
  $ADRunSpace.SessionStateProxy.setVariable("ADHashTable", $ADHashTable)
  
  # Custom code
  $ADPowerShell = [PowerShell]::Create()
  $ADPowerShell.Runspace = $ADRunSpace
  $handle = $ADPowerShell.AddScript({
   
   # Set simple value
   $ADHashTable.tmptxt = "Beta" + "`n"
   
   # Core code is here, this may take > 10 minutes.
   # Update GUI (richtextbox) without freezing it.
   # Import new values to GUI richtextbox.
   
   <#
   # This is simple example
   $ADUsers = Get-ADUser -Filter * -Properties *
   $ADUsers | % {
    # Append user displayName to richtextbox
    # Is is possible to user $ADHashTable.tmptxt variable
   }
   #>
   
  }).BeginInvoke()
  
  # Wait for the handle job to finish
  while (-Not $handle.IsCompleted) {
   Start-Sleep -Milliseconds 100
  }
  
  # Update simple value
  $richtextbox1.AppendText($ADHashTable.tmptxt)
  
  # Update last value
  $richtextbox1.AppendText("All done")
  
  # Close the session and dispose of PowerShell object
  $ADPowerShell.EndInvoke($handle)
  $ADRunSpace.Dispose()
  
 }
 
 # --End User Generated Script--
 #----------------------------------------------
 #region Generated Events
 #----------------------------------------------
 
 $Form_StateCorrection_Load=
 {
  #Correct the initial state of the form to prevent the .Net maximized form issue
  $form1.WindowState = $InitialFormWindowState
 }
 
 $Form_Cleanup_FormClosed=
 {
  #Remove all event handlers from the controls
  try
  {
   $button1.remove_Click($button1_Click)
   $richtextbox1.remove_TextChanged($richtextbox1_TextChanged)
   $form1.remove_Load($form1_Load)
   $form1.remove_Load($Form_StateCorrection_Load)
   $form1.remove_FormClosed($Form_Cleanup_FormClosed)
  }
  catch [Exception]
  { }
 }
 #endregion Generated Events

 #----------------------------------------------
 #region Generated Form Code
 #----------------------------------------------
 $form1.SuspendLayout()
 #
 # form1
 #
 $form1.Controls.Add($button1)
 $form1.Controls.Add($richtextbox1)
 $form1.ClientSize = '466, 465'
 $form1.Name = "form1"
 $form1.Text = "Form"
 $form1.add_Load($form1_Load)
 #
 # button1
 #
 $button1.Location = '12, 317'
 $button1.Name = "button1"
 $button1.Size = '75, 23'
 $button1.TabIndex = 1
 $button1.Text = "button1"
 $button1.UseVisualStyleBackColor = $True
 $button1.add_Click($button1_Click)
 #
 # richtextbox1
 #
 $richtextbox1.Location = '12, 12'
 $richtextbox1.Name = "richtextbox1"
 $richtextbox1.Size = '442, 290'
 $richtextbox1.TabIndex = 0
 $richtextbox1.Text = ""
 $richtextbox1.add_TextChanged($richtextbox1_TextChanged)
 $form1.ResumeLayout()
 #endregion Generated Form Code

 #----------------------------------------------

 #Save the initial state of the form
 $InitialFormWindowState = $form1.WindowState
 #Init the OnLoad event to correct the initial state of the form
 $form1.add_Load($Form_StateCorrection_Load)
 #Clean up the control events
 $form1.add_FormClosed($Form_Cleanup_FormClosed)
 #Show the Form
 return $form1.ShowDialog()

} #End Function

#Call the form
Call-GUIrefresh_psf | Out-Null

Impersonate user when accessing Microsoft SQL Server from powershell using Windows Authentication

$
0
0

Hi All,

Below is the powershell script to connect a SQL DB using windows authentication by impersonating a user. The user should have login access to the server. Script can be highly useful when service id is used to access DB using powershell.

[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
$ds=$null
$conn = New-Object -typeName Microsoft.SqlServer.Management.Smo.Server -argumentList "Servername"
$db = New-Object Microsoft.SqlServer.Management.Smo.Database

$conn.ConnectionContext.ConnectAsUser = $true 
$conn.ConnectionContext.LoginSecure=$true
$conn.ConnectionContext.ConnectAsUserName = "username"
$conn.ConnectionContext.ConnectAsUserPassword ="password
$conn.Loginmode
$db = $conn.Databases.Item("dbname")
$ds = $db.ExecuteWithResults("select top 10 Name from Tablename")

Foreach ($t in $ds.Tables)
{
   Foreach ($r in $t.Rows)
   {
      Foreach ($c in $t.Columns)
      {
          Write-Host $c.ColumnName "=" $r.Item($c)
      }
   }
}

Powershell foreach -parallel WMI query operation did not complete within the allotted timeout of 00:00:30

$
0
0

Hello!

I'm running the following script in PS 3.0:

Workflow Test-My-WF {  
  $servers=Get-Content -Path "ser.txt"
  foreach -parallel ($server in $servers) {
    $proci = (Get-WmiObject win32_Processor -ComputerName $server | select name)
    if($proci)
        {
        $proci
        }
       }
}
Test-My-WF

I get some results but I endupt with the following error after 30sec.

The operation did not complete within the allotted timeout of 00:00:30. The time allotted to this operation may have been a portion of a
longer timeout.
At Test-My-WF:8 char:8
+
    + CategoryInfo          : InvalidResult: (:) [], TimeoutException
    + FullyQualifiedErrorId : JobStateFailed

Is it possible to change the timeout ? (running the same workflow against anothet WMI class for example W32_Process runs faster and I do not experience the same problem).

Many thanks in advance for your answers!



How do I access this forum using an RSS feed?

$
0
0

How do I access this forum using an RSS feed?

I used to be able to do that.

Get-ADUser and Get-ADPrincipalGroupMembership combined

$
0
0

I'm trying to get a list of template user account and what their membership are exported to a csv file. I'm trying to combine the tables on them but having a hard time figuring it out. I spent the day racking my brain on this and figured I would reach out for help. This gets all my template users.

Import-Module ActiveDirectory

$User = "*Template*"

$usernames = (Get-ADUser -Filter "DisplayName -like '*$User*'" -Properties * | format-table Displayname, SamAccountName)

$usernames

I can use this to get all the members of the groups, but since the groups repeat it doesnt break down where one user stops and the others begin. 

$groups = Get-ADUser -Filter "SamAccountName -like '*$Usr*'" -Properties DisplayName | foreach-object{Get-ADPrincipalGroupMembership -Identity $_.SamAccountName} | format-table name

I was thinking of joining the tables but that wasnt much help to me since I cant figure out what to join on. I also thought about looping through the first table with a foreach loop but it was assigning the whole table in the first pass and displaying nothing. If anyone could help or suggest something, I would greatly appreciate.

Matt


More Guru Winners for February 2015 in the PowerShell category and many others!

$
0
0

It's been a busy week that also saw the TECHNET WIKI SUMMIT 2015

Then we had the results for February's TechNet Guru competition ALSO posted!

http://blogs.technet.com/b/wikininjas/archive/2015/03/19/technet-guru-february-2015.aspx

Below is a summary of the medal winners for December. The last column being a few of the comments from the judges.

Unfortunately, runners up and their judge feedback comments had to be trimmed from THIS post, to fit into the forum's 60,000 character limit, however the full version is available on TechNet Wiki in the link above.

Some articles only just missed out, so we may be returning to discuss those too, in future blogs.
 

Guru Award BizTalk Technical Guru - February 2015  

Gold Award Winner

Steef-Jan WiggersBizTalk Server 2013 R2 Instrumenting a custom pipeline component with ETWMandi Ohlinger: "Always a fan of helping our custom pipeline users. Great addition to this group."
Sandro Pereira: "Images, format, descriptions, code and topic are excellent once again good work Steef-Jan."

Silver Award Winner

Vignesh SukumarBizTalk BAM (Business Activity Monitoring)Sandro Pereira: "Great job on this article! Well explained and nice pictures, however the article format need to be improved and some proofreading is need"
Mandi Ohlinger: "Welcome to the 'I heart BAM' fan club. Nice job on this topic. A MUST read for new-to-BAM users. "

Bronze Award Winner

Steef-Jan WiggersBizTalk Server 2013 R2 Instrumenting BAM Activity Tracking with ETWSandro Pereira: "Images, format, descriptions, code and topic are excellent once again good work Steef-Jan."
Mandi Ohlinger: "ETW for BAM Activities - LOVE it. Nice use of the Framework. "

Guru Award Forefront Identity Manager Technical Guru - February 2015  

Gold Award Winner

Wim BeckFIM2010: Filter objects on exportPG: "Simple, targeted but nice article, nice layout. "
Søren Granfeldt: "Nice. Would be perfect with a complete code sample."

Guru Award Microsoft Azure Technical Guru - February 2015  

Gold Award Winner

saramgsilvaAzure Mobile Services: How to see the log files in serverJH: "Log files are one of the most important things in a production environment. This article shows hows you can do that for the Azure Mobile Services in a nice and easy way."
Alan Carlos: "Great article!"
Ed Price: "Very useful topic! These are a great set of articles!"

Silver Award Winner

saramgsilvaAzure Mobile Services: How to see the WebConfig file publishedEd Price: "Great detail and fantastic use of images! I love all the in-line links!"
JH: "Sometimes it is hard to tell when working in a multi-environment what configuration was published to the Server. The article shows short and easy how to do that for the Azure Mobile Services."

Guru Award Miscellaneous Technical Guru - February 2015  

Gold Award Winner

Arleta WanatRetrieve all site mailboxes in your Office 365 tenantDurval Ramos: "This article has a well content, images and code that help to understand the solution. It has References and was Translated into more two languages. Good job!"
Richard Mueller: "Good links. A great tutorial."

Silver Award Winner

Andy ONeillSilverlight: No Need to BringIntoViewDurval Ramos: "A well formatted article is easier and more pleasant to read. This script is useful"
Richard Mueller: "Good demonstration of a new feature."

Bronze Award Winner

Chen VPowerShell : Enable Auto Reply for Shared Mail BoxDurval Ramos: " A good solution originated of TechNet Forum. The script and images make it easy to understand and ensure you get the best interest to reader."
Richard Mueller: "Good documentation of this feature."

Guru Award SharePoint 2010 / 2013 Technical Guru - February 2015  

Gold Award Winner

Geetanjali AroraSharePoint Online : Performing Batch Operations using REST APIKB: "Very well explained article on a new and much awaited feature. Although Andrew Connell already explained this topic in several posts, this article still contains added value."
Ed Price: "I love the History section. The formatting is amazing. And the References and See Also sections at the bottom are great icing on the cake. This is an important topic that's done incredibly well!"

Silver Award Winner

Matthew YarlettUsing the SpellCheck Webservice with the TinyMCE Richtext Editor and AngularJS in Office 365KB: "I read this article with growing interest, it contains a lot of added value. Very well and in-depth explanation. "
Ed Price: "Great scenario! Good use of images, code, detail, and References! Could possibly use a greater breakdown and explanation of the code. This article just gets more and more interesting and valuable as you read it! Great job!"

Bronze Award Winner

Arleta WanatSharePoint Online: Turn on support for multiple content types in a list or library using PowershellKB: "Really nice, interesting and detailed article!"
Ed Price: "The Content Types section helps explain this a lot! I also love the downloads at the end. What a fantastic resource!"

Guru Award Small Basic Technical Guru - February 2015  

Gold Award Winner

Nonki TakahashiSmall Basic: Key InputMichiel Van Hoorn: "Great improvement."
RZ: "Very nice explanation and examples of key input handling"

Silver Award Winner

Ed Price - MSFTSmall Basic: The History of the Logo TurtleRZ: "Turtle (Logo) was the first programming language for many, including perhaps some of the Small Basic prorammers. Nice article explaining the history."
Michiel Van Hoorn: "A nice background article and hopefull inspiration for those who want to start in robotics"

Bronze Award Winner

Nonki TakahashiSmall Basic: TechNet Wiki Article ListMichiel Van Hoorn: "This is great! Perfect as a local cache of the articles. "
RZ: "A good example"

Guru Award SQL BI and Power BI Technical Guru - February 2015  

Gold Award Winner

Sylvain PONTOREAUPowerBI API in .NetRB: "Great walkthrough. Looking forward for the WP8 version of the app ;)"
PT: "Sylvain, very nice job with this. This is a timely topic about an emerging product that has great potential. This is a very good example of a well-written post on an interesting subject with enough information to be valuable to a solution developer. I will personally take time to explore the Power BI API and use your examples. "

Guru Award SQL Server General and Database Engine Technical Guru - February 2015  

Gold Award Winner

Ronen ArielySQL Server Books OnlineAM: "Thank you for sharing this with us. It is quite informative and let us get familiar with BOL after the change from previous versins."
Ed Price: "Nice! A very helpful introduction to Books Online! It also tells my technical writer friends that their hard work is appreciated! =^)"

Silver Award Winner

Durval RamosHow to Collect Events and Errors on SQL ServerEd Price: "Fantastic solution! A great resource that's amazingly well written with formatting, clear parameters, images, References, and a See Also section! And it even comes in Portuguese! Great article!"
AM: "Thank you for sharing this with us. A good source to learn about our SQL Server instances. "

Guru Award System Center Technical Guru - February 2015  

Gold Award Winner

MarkusEliassonTroubleshoot ID 32008: DPM cannot protect this SharePoint farm...Ed Price: "An important topic that's very clear with great formatting and a good use of an image!"

Silver Award Winner

t.c.richManaging Priorities of Client Polices and A/V Policies in SCCMEd Price: "I love the descriptions, breakdown of sections, and code formatting! Great article!" 

Bronze Award Winner

Mr XHow to copy SMSTS.log when a Task Sequence fails in SCCMEd Price: "A very helpful table and a good contribution to the community! Mr X again thinks of important content gaps to fill!"

Guru Award Transact-SQL Technical Guru - February 2015  

Gold Award Winner

Saeid HasaniT-SQL: How the Order of Elements in the ORDER BY Clause Implemented in the Output ResultDurval Ramos: "Very well structured and with examples that clarify how a T-SQL statement can change the data output order."
Richard Mueller: "Good use of Wiki guidelines and great examples."

Silver Award Winner

Ronen ArielyFree E-Books about SQL and Transact-SQL languagesRichard Mueller: "An excellent collection and a great idea."
Durval Ramos: "A good initiative. Very useful !!!"

Bronze Award Winner

Ricardo LacerdaDeclare Cursor (Transact-SQL) versus Window with Over - Running Totals - Accumulated EarningsDurval Ramos: "The "Window function" sample was well presented, but it was unclear how the chart was generated."
Richard Mueller: "A new idea that can be very useful. Grammar needs work"

Guru Award Visual Basic Technical Guru - February 2015  

Gold Award Winner

Emiliano MussoGenetic algorithm to solve 2D Mazes in Visual BasicMR: "Great article! Love to see an application for AI in a simple game"
Durval Ramos: "This article is well documented with images and your code clarifying important details. It also has References, a very useful video and your project available for download in "MSDN Code" !"
Richard Mueller: "Incredible concept and code. Grammar needs work."

Silver Award Winner

Paul IshakMultiHeadedTrackBar ControlDurval Ramos: "Very interesting article, with methods and properties well documented. Your project was available in "MSDN Code" which facilitates the understanding of solution."
Richard Mueller: "Amazing work. Extensive code but with lots of comments. Needs a TOC"

Bronze Award Winner

tommytwotrainUsing Trigonometry to draw graphic curves in VB.NET part 2.MR: "Great continuation. Love the usage of the code for circle text"
Durval Ramos: "The article is interesting, but It's need to work better commenting about assemblies referenced on project and also structure your content into sections."
Richard Mueller: "Good tutorial and example code demonstrating basic concepts. Avoid first person."

Guru Award Visual C# Technical Guru - February 2015  

Gold Award Winner

Magnus (MM8)C#: Enumerating collections that changeJaliya Udagedara: "Great article. Has a thorough and to the point explanation of problem and the solution with code samples. Loved it!"
Carmelo La Monica: "Very useful and exhaustive about errors at runtime in these circumstances. Congratulations"

Silver Award Winner

Andy ONeillc#: Practical PolyCarmelo La Monica: "Fantastic artcle. Very detailed and exhaustive, congratulations ."
Jaliya Udagedara: "Definitely worth reading this. Explains somewhat advance topic along with a fundamental concept of programming. "

Guru Award Wiki and Portals Technical Guru - February 2015  

Gold Award Winner

Durval RamosWiki: Microsoft Short URLs Personalized by SXPPG: "Nice idea, lots of potential to grow, really needs some more community attention."
Richard Mueller: "An excellent idea. Good use of Wiki guidelines."

Guru Award Windows Phone and Windows Store Apps Technical Guru - February 2015  

Gold Award Winner

Carmelo La MonicaWindows Phone 8: control Nokia Maps (Part 3)JH: "Part 3 of the series how to work with the Nokia maps control. As the previous articles this one contains a lot of code snippets and some pictures. Good work!"
Ed Price: "A great topic, a fantastic breakdown of sections with clear descriptions, and a nice mix of code formatting and helpful images! Another stellar article from Carmelo! Great job including the link back at the end to the portal article!"

Guru Award Windows PowerShell Technical Guru - February 2015  

Gold Award Winner

Richard MuellerDocument Your Active Directory OrganizationAlan Carlos: "Wow! Great article, congratulations!!! Very detailed!"
Chen V: "Excellent Article - I liked return to top as well."
Ed Price: "Wow! It's like a professional whitepaper! It's a valuable topic that's done with intricate detail! I love the images, diagrams, code blocks, and it ends very well with more resources and Wiki articles! The article just keeps digging deeper and deeper! Awesome job on this!"

Silver Award Winner

DexterPOSHPowerShell + REST API : Invoke-RestMethod GotchaChen V: "Good Article. TOC might have made this more rich! "
Ed Price: "This is a good topic with some great content. It could benefit from sections and a TOC, as well as a References and See Also sections at the end. The inline links are helpful. Could "

Bronze Award Winner

DexterPOSHPowerShell Trick : Search & highlight text in MS WordEd Price: "This is a great solution, with some helpful Q&A in the comments!"

 

Guru Award Windows Presentation Foundation (WPF) Technical Guru - February 2015  

Gold Award Winner

Andy ONeillLookless ControlsKJ: "WPF can definitely be confusing when devs first encounter it. Like the way you break it down."
Ed Price: "Wow! Fantastic explanations that are very clear and deep! The images and code bring it to life!"

Silver Award Winner

Andy ONeillOnly One ParentKJ: "Same iwith this one, good 101 intro"
Ed Price: "Another great tip! I love the detail here as well! Those snippets help a lot!"

Bronze Award Winner

Andy ONeillBind to Current Item of CollectionKJ: "Feel like this topic has a lot of coverage out there, but it can't hurt to hammer on databinding yet one more time :) "
Ed Price: "Fantastic topic with great execution! Although these could benefit from References and See Also wiki sections at the end, the Inline links help a lot!"

Guru Award Windows Server Technical Guru - February 2015  

Gold Award Winner

Mr XPing for BeginnersMark Parris: "A good introduction with additional content."
JM: "Great article idea and an excellent article that will be useful to many, thanks for your contribution."
Philippe Levesque: "Good article that show a usefull utility for basic troubleshooting"

Silver Award Winner

Richard MuellerActive Directory: Get-ADFineGrainedPasswordPolicy Default and Extended PropertiesMark Parris: "An Interesting insight on FGPP and their extended properties."
JM: "This is a good piece of detailed information about this PowerShell cmdlet, thanks for sharing."
Philippe Levesque: "Great article ! Illustrating some cmdlet's output when a user got assigned policy versus a user with the default domain policy could be a good idea."

Bronze Award Winner

Richard MuellerActive Directory: Get-ADServiceAccount Default and Extended PropertiesMark Parris: "A useful nugget of information."
JM: "More very useful information about an AD cmdlet, thanks!"
Philippe Levesque: "Good article !"

As mentioned above, runners up and comments were removed from this post, to fit into the forum's 60,000 character limit.

You will find the complete post, comments and feedback on the main announcement post.

Please join the discussion, add a comment, or suggest future categories.

If you have not yet contributed an article for this month, and you think you can write a more useful, clever, or better produced wiki article than the winners above, THERE'S STILL TIME! :D

 

Best regards,
Pete Laker

More about the TechNet Guru Awards:


#PEJL
Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over toTechNet Wiki, for future generations to benefit from! You'll never get archived again, and you could win weekly awards!

Have you got what it takes o become this month's TechNet Technical Guru? Join a long list of well known community big hitters, show your knowledge and prowess in your favoured technologies!

Help joining some scripts together (mail enabling accounts)

$
0
0

Hi All,

I'm currently working on a runbook in Orchestrator for onboarding users. I need to mail enable these users in exchange and place them into a database based on the first initial of their first name.

I have adapted this script to do the enabling - http://myitforum.com/myitforumwp/2014/09/29/create-exchange-2013-mailboxes-in-bulk-using-powershell/

And i found this that will do the database part - http://blogs.msdn.com/b/akashb/archive/2008/08/07/8841495.aspx

Now i just need some help with combining the two! If anyone can help me i would be most grateful. 


HughMc

Get-aduser -Filter email address

$
0
0

Hi, I have a csv file with a email address and the employ ID. I which to update the emply id according to the email address

csv:

Email;employerID;FirstName;LastName;

a.a@test.com;123456789;a;a;

b.b@test.com;789456123;b;b;

I tried querying the user according to email but the user is not found:

$test = Import-csv -Path \\tsclient\c\temp\test.csv -delimiter ";"
Foreach ($u in $test) {Get-aduser -Filter { emailaddress -Like $u.email} -Properties emailaddress}


Which i find strange, because when i run following commandlet the correct address are displayed.

$test = Import-csv -Path \\tsclient\c\temp\test.csv -delimiter ";"
Foreach ($u in $test) {write-host $u.email}

I even tried, but same result:

$test = Import-csv -Path \\tsclient\c\temp\test.csv -delimiter ";"
Foreach ($u in $test) {Get-aduser -Filter { emailaddress -Like $($u.email)} -Properties emailaddress}

What am i doing wrong?


Answers provided are coming from personal experience, and come with no warranty of success. I as everybody else do make mistakes.

Formatting repadmin output

$
0
0

Hi all,

I'm trying to format output of repadmin /replsummary command within powershell.

In my script, very first thing, i execute repadmin /replsummary within powershell and format output a little bit as follow:

$myRepInfo = @(repadmin /replsum * /bysrc /bydest /sort:delta)
$msg = $myRepInfo | Where-Object { $_ } | ForEach-Object { $_ -replace $_,"$_`n" }
$last = $msg -replace "Beginning data collection for replication summary, this may take awhile:",""
$last >> C:\scripts\repsummary.log

But when i try to get-content of replsummary.txt, i can not sort output using columns since within repsummary.txt there is no chance to use delimeter or columns, it's really a bad designed output.

Here is the actual repadmin /replsummary output file:

What i want to achieve is to use repsummary txt output to create a table in powershell that includes Source,Destination and Error fields only. So that i will be able to create a html table and assign red color for each failed row.

Thanks in advance.

Active Directory User information

$
0
0

Hi there,

I'm new to PowerShell and would like to get assistance on the following requirements: Get the list of all Active Directory groups, their associated members along with information such as windows login, name, and manager name.

Any assistance would be much appreciated.

Thank you


Working with spreadsheet

$
0
0

The script breaks if one of the cells in spreadsheet is empty. I use if statement to check for null but the problem is with "$user = Get-ADUser $item.UserLogonName -Properties department,mail". This line does not allow to pass null value. How do I fix this?

for example, The script breaks if Mail cell is empty

$path     = Split-Path -parent $MyInvocation.MyCommand.Definition
$newpath  = $path + "\edituser.csv"
$item = Import-Csv $newpath
$dnsroot  = (Get-ADDomain).DNSRoot

Function edit-user {
 If ($item.UserLogonName -eq "") {
        Write-Host "[ERROR]`t Please provide valid user logon name in spreadsheet."  -ForegroundColor Red
      } Else {
        $user = Get-ADUser $item.UserLogonName -Properties department,mail
     
       
        if ($item.department -eq "") {
            break
        } else {
            $user.department = $item.Department
        }
        if ($item.mail -eq "") {
            break
        } else {
            $user.mail = $item.Mail
        }

        Set-ADUser -instance $user


        }

    }


Write-Host "STARTED SCRIPT`r`n"  -ForegroundColor Cyan
edit-user
Write-Host "STOPPED SCRIPT" -ForegroundColor Cyan

Read-Host Multiple lines

$
0
0

Hi,

 I am writing a script which waits for user input initially, actually i want user to enter multiple emailids through read-host and i want to save that in a file in specific location. Below is the code

read-host " Enter the email ids to which you want to send alerts" > C:\mydrive\tomail.txt
$lines=(Get-Content C:mydrive\tomail.txt)
$newcontent = foreach ($line in $lines) { $line.Trim()} 
$newcontent | out-file C:mydrive\tomail.txt

What i am doing here is , i am getting the emailds and trimming it and storing in a file.

When i execute the above script in ISE , i can use Shift enter to enter multiple email ids, however when i run the script in powershell console it doesnt work, any ideas?

Change Default Calendar Permissions

$
0
0

Hello,

I have asked this on the email and calendar forum but it's been suggested that I post here.

We would like all users to have access to the calendars of all other users but seeing full details rather than the default free/busy.

I've been given the command below which is for one user and wonder if it is possible to tweak to apply to all users?

Add-MailboxFolderPermission -Identity SharedMailboxName:\calendar -User UserName -AccessRights Editor


itswt

Get-Childitem $dir -Include not picking up any files

$
0
0

I've noticed my script is not capturing any files if I have the filetype added in the -Include. For example I have this config value:

<FileTypesToDelete>*.txt,*.log,*.mf,*.xml</FileTypesToDelete>

and then in my script I setting my variable like this:

$fileTypesToDelete = @($configfile.Settings.FileTypesToDelete.Split(",").Trim())

and finally i want to get any of these files:

$logFiles = Get-Childitem $dir -Include $fileTypesToDelete[0],$fileTypesToDelete[1],$fileTypesToDelete[2], $liveSiteLogs -Recurse -Exclude $fileExclusions[0],$fileExclusions[1] | Where {$_.LastWriteTime -le "$LastWrite"}

am I missing something obvious? I i remove the -Include from the above line and write the files to the host then all the files I'm expecting to see are returned no problem

Remove Variables on Script Completion

$
0
0

Hi,

Is there a way to remove variables that I create in a script after it has finished running. I have a script with a dozen odd variables which I would like to delete after the script has done its job.

The options I have seen are:

  • Close down the Powershell environment and restart
  • Use Remove-Variable command

If I use get-variable and limit the scope to script I see other variables which I did not define. I would only like to remove the variables which I have defined. 

Any suggestions would be appreciated. 

Regards,

MobileIAm

Viewing all 21975 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>