Quantcast
Channel: Windows PowerShell Forum
Viewing all 2562 articles
Browse latest View live

Run EXE on a remote pc

$
0
0

Can you help me with the following code, i mean i have tried all the following script blocks to execute an application on a remote computer and i have failed to required task with the all the following.

$machines = Get-Content "c:\Users\metho\Desktop\1.txt" [ScriptBlock] $script = {

# I have tried this

# [System.Diagnostics.Process]::Start("C:\ninite.exe") # [System.Diagnostics.Process]::Start("calc");

# I have tried this

# $startprocess = ([wmiClass]"\\.\ROOT\CIMV2:win32_process") # $startprocess.create("c:\ninite.exe")

# I have tried this

# $startprocess = ([wmiClass]"\\.\ROOT\CIMV2:win32_process") # $startprocess.create.Invoke("c:\ninite.exe")

# I have tried this

[System.Diagnostics.Process]::Start("c:\ninite.exe").WaitForExit() } $cred = Get-Credential $sessions = $machines | New-PSSession -Credential $cred Invoke-Command -ScriptBlock $script -Session $sessions $sessions | Remove-PSSession

i have looked at the following links to understand or determine if i am missing something but everything looks ok, for example start-process and system.diagnostics.process does execute the process on a remote pc but there is no interaction with the desktop or it doesnt installs it but its running in the background or seems to be running. 

scripting guy

Running EXEs

Any sort of help would be much appricated!


Changing Computer Descriptions Remotely using Powershell

$
0
0

Hello,

I am the Network Admin for a small college that has a little over 300 computers. I want to be able to use PowerShell to change the computer descriptions on those machines from my desk. I have PowerShell 3.0 installed on my system. I am new to PowerShell so I could use some step by step instructions on what to do.

For instance:

I have a computer in my network that has a Computer Name of "19XP9175" and a description of "Optiplex 320 - Doreen Lane".

I would like to change the description to read "O320-Doreen lane"  from my system using PowerShell 3.0.

Can you give me some pointers on how to do this?

Thanks

Daryl

Access MS Word documents in SharePoint with PowerShell.

$
0
0

Could someone help me with the following task? I have hundreds of MS Word documents on SharePoint. I need PowerShell script to be able to access documents in SharePoint, enumerate them and edit if necessary.

call/execute a file .bat

$
0
0
Hi, guys!

How to make an algorithm in powershell (ps1), which call/execute a file .bat?
And its result must be stored in a variable.
Please can you show some examples.

Note:
This .bat contain statements that do not exist in PowerShell module. They are of SharePoint 2007 stsadm tool.

Se eu estiver respondendo a sua pergunta, e a mesma tiver utilidade. Vote com útil. Se for minha dúvida, e você me ajudar na solução, terei o maior prazer em votar como útil. Esse é o espírito do Forum MSDN !!! Valew !

Convert HTML file/table to XML/Excel

$
0
0

Hi,

I am using a script to export mailbox audit log, but it is by default generating the report in HTML, Our requirement is to generate the report in CSV or in Excel file and also wanted to put a date range so that instead of looking for beaging the script will export the report for a specified date. I really don't understand powershell much. Please guide me. Below is the script I am using

<#
    .SYNOPSIS
    Creates a HTML Report to show Mailbox Audit Logs for a single Exchange 2010 Mailbox or all AuditEnabled Mailboxes.
  
    Serkan VAROGLU
 
 http:\\Mshowto.org
 http:\\Get-Mailbox.org
 Twitter:@SRKNVRGL
 
 THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
 RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
 
 Version 1.0, 15 March 2012
 
    .DESCRIPTION
 
    Creates a HTML Report to show Mailbox Audit Logging for Exchange 2010 Mailbox or Mailboxes.
 
 .PARAMETER Mailbox
    If you want to report a single mailbox use "Mailbox" parameter with alias input.
 
 .SWITCH All
    If you want to report all AuditEnabled mailboxes use "All" switch.
 
 .SWITCH UniqueFileName
  If you use UniqueFileName switch the output name will be "SAMAccountName-DayMonthYear-HourMinuteSecond.html" (Example: srknvrgl-15032012-163420.html)
 
 .IMPORTANT NOTES
 -Please make sure you have write permission on the folder that you are running the script from.
 -If you use All switch and Mailbox Parameter at the same time. All switch will be used.
 -By default the report will be generated as "SAMAccountName.html" (Example: srknvrgl.html)in the directory that you ran the script from.
 -If you are running the script in scheduled intervals you might want to use UniqueFileName switch to keep all versions if not the report will be overridden.
 
 .EXAMPLES
   
 For a Single Mailbox
 .\Report-MailboxAuditLog -Mailbox srknvrgl
 
 For all AuditEnabled Mailboxes
 .\Report-MailboxAuditLog -All
 
 For a Single Mailbox with Unique File Name Output
 .\Report-MailboxAuditLog -Mailbox srknvrgl -UniqueFileName
 
 For all mailboxes with Unique File Name Output
 .\Report-MailboxAuditLog -All -UniqueFileName
#>
param (
[Parameter(Position=0,Mandatory=$false,ValueFromPipeline=$false)][string]$Mailbox,
[Parameter(Position=1,Mandatory=$false,ValueFromPipeline=$false)][switch]$All,
[Parameter(Position=2,Mandatory=$false,ValueFromPipeline=$false)][switch]$UniqueFileName
)
$Watch = [System.Diagnostics.Stopwatch]::StartNew()
$WarningPreference="SilentlyContinue"
$ErrorActionPreference = "Silentlycontinue"
if ((!$All) -and (!$Mailbox)){Write-host -ForegroundColor Red "Please use either Mailbox parameter or All switch. ""All"" switch will let you report all mailboxes. ""Mailbox"" Parameter will report a single mailbox"
exit}
function _Progress
{
    param($PercentComplete,$Status)
    Write-Progre`ss -id 1 -activity "Report for Mailboxes" -status $Status -percentComplete ($PercentComplete)
}
_Progress (10) "Searching accounts with Audit ByPass Enabled"
#Find accounts with Audit ByPass Association
$bypassenabled=Get-MailboxAuditBypassAssociation -resultsize unlimited | ?{$_.AuditBypassEnabled -eq $True}
function auditreport
{
  param($Mailbox)
  $c=0
  $MailboxName=Get-Mailbox $Mailbox -ErrorAction SilentlyContinue
  if (!$MailboxName) {Write-host -ForegroundColor Red "Please make sure you typed correct alias! Script couldn't find any mailbox with that alias!"} else
  {
   if($MailboxName.AuditEnabled -eq $False) {Write-host -ForegroundColor Red "Audit Logging is not enabled on this Mailbox!"}  else
    {
     #Get Number of Events
     $auditsummary=Get-MailboxFolderStatistics $MailboxName.WindowsEmailAddress -FolderScope RecoverableItems | ?{$_.Name -eq "Audits"}
     #Collect MailboxAudit Log for the mailbox
     $audit=Search-MailboxAuditlog $MailboxName.WindowsEmailAddress -ShowDetails -Resultsize 250000
     #What is monitored for Admin Access
     Foreach ($Action in $MailboxName.AuditAdmin)
        {
            $AdminActions+="$Action"
            $AdminActions+=" , "
        }
     #What is monitored for Delegate Access
     Foreach ($Action in $MailboxName.AuditDelegate)
        {
            $DelegateActions+="$Action"
            $DelegateActions+=" , "
        }
     #What is monitored for Owner
     Foreach ($Action in $MailboxName.AuditOwner)
        {
            $OwnerActions+="$Action"
            $OwnerActions+=" , "
        }
     #Calculate Item Count in each Event
     Foreach ($event in $audit)
     {
      If (!($event.ItemId))
       {
        $SourceItemCount=($event.SourceItems | measure-object).count
       }
       else
       {
        $SourceItemCount=($event.ItemId | measure-object).count
       }
      
      
      $EventTbldata+="<tr><td>$($event.Operation)"
      $EventTbldata+="<td>$($event.OperationResult)</td>"
      $EventTbldata+="<td>$($event.LogonUserDisplayName)</td>"
      $EventTbldata+="<td>$($event.LogonType)</td>"
      $EventTbldata+="<td>$($event.ClientInfoString)</td>"
      $EventTbldata+="<td>$($event.ClientIPAddress)</td>"
      $EventTbldata+="<td>$($event.FolderPathName)</td>"
      $EventTbldata+="<td>$($event.ItemSubject)</td>"
      $EventTbldata+="<td>$($SourceItemCount)</td>"
      $EventTbldata+="<td>$($event.LastAccessed)</td></tr>"
     }

     $Header="<html><body>
      <font size=""1"" face=""Arial,sans-serif"">
      <h3 align=""center"">$($MailboxName) Mailbox Audit Log Report</h3>
      <a name=""top""><h4 align=""center"">Generated $((Get-Date).ToString())</h4></a>"
     $EventTblHeader="<table border=""1"" bordercolor=""#4384D3"" cellpadding=""3"" style=""font-size:8pt;font-family:Arial,sans-serif"" width=""100%""><tbody>
     <tr bgcolor=""#4384D3"" align=""center"">
     <td><font color=""#FFFFFF"">Operation</font></td>
     <td><font color=""#FFFFFF"">Operation Result</font></td>
     <td><font color=""#FFFFFF"">Logon User Display Name</font></td>
     <td><font color=""#FFFFFF"">Logon Type</font></td>
     <td><font color=""#FFFFFF"">Client Info</font></td>
     <td><font color=""#FFFFFF"">Client IP Address</font></td>
     <td><font color=""#FFFFFF"">Folder Path</font></td>
     <td><font color=""#FFFFFF"">Item Subject</font></td>
     <td><font color=""#FFFFFF"">Item Count</font></td>
     <td><font color=""#FFFFFF"">Last Accessed</font></td>
     </tr>
     "
     $EventTbl=$EventTblHeader+$EventTbldata+"</tbody></table>"
     $Footer="<font size=""1"" face=""Arial,sans-serif"">Scripted by <a href=""Serkan">http://www.get-mailbox.org"">Serkan Varoglu</a>. 
      Elapsed Time To Complete This Report: $($Watch.Elapsed.Minutes.ToString()):$($Watch.Elapsed.Seconds.ToString())</font></body></html>"
     $BypassTbl0="<center><table style=""font-size:8pt;font-family:Arial,sans-serif"" border=""1"" bordercolor=""#FFE87C"" cellpadding=""3""><tr align=""center""><td bgcolor=""#FFE87C"" colspan=""10"">Mailbox Audit Bypass Association is Enabled on these accounts. These accounts are not logged in Audit Logging.</td></tr><tr>"
     foreach ($bypass in $bypassenabled)
      {
       if ($c -eq 10)
       {
        $BypassTbl1+="</tr><tr><td>$($bypass.name)</td>"
        $c=1
       }
       else
       {
        $BypassTbl1+="<td>$($bypass.name)</td>"
        $c++
       }
      }
     $BypassTbl2="</tr></table></center>"
     if (!$bypassenabled)
      {
      $BypassTbl=""
      }
      else
      {
      $BypassTbl=$BypassTbl0+$BypassTbl1+$BypassTbl2
      }
     $MailboxTbl="
     <table border=""1"" bordercolor=""#4384D3"" cellpadding=""3"" style=""font-size:8pt;font-family:Arial,sans-serif"" width=""100%"">
     <tbody>
     <tr bgcolor=""#4384D3"" align=""center"">
     <td><font color=""#FFFFFF"">Total Events</font></td>
     <td><font color=""#FFFFFF"">Audit Events Logged for Admin</font></td>
     <td><font color=""#FFFFFF"">Audit Events Logged for Delegates</font></td>
     <td><font color=""#FFFFFF"">Audit Events Logged for Mailbox Owner</font></td>
     </tr>
     <tr>
     <td>$($auditsummary.ItemsInFolder)</td>
     <td>$($AdminActions)</td>
     <td>$($DelegateActions)</td>
     <td>$($OwnerActions)</td>
     </tr>
     </tbody>
     </table>
     "
     if (!$auditsummary)
      {
       $Output=$Header+$BypassTbl+"<br>"+$MailboxTbl+"<br><center>Nothing Logged Yet.<br></center>"+$Footer
      }
     else
      {
       $Output=$Header+$BypassTbl+"<br>"+$MailboxTbl+$EventTbl+$Footer
      }
     $t = Get-Date -UFormat %d%m%Y-%H%M%S
     if($UniqueFileName.Ispresent -eq $True)
      {
       $HTMLReport = "$($MailboxName.WindowsEmailAddress)-$t.html"
      }
      else
      {
       $HTMLReport = "$($MailboxName.WindowsEmailAddress).html"
      }
     $Output | Out-File $HTMLReport
     Write-Host "Report for " $MailboxName " : " $HTMLReport
    }
  }
}
if ($All.Ispresent-eq $True)
{
 $AllMailboxes=Get-Mailbox -ResultSize Unlimited| ?{$_.AuditEnabled -eq $True}
 foreach ($AllMailbox in $AllMailboxes)
  {
  _Progress (($i*95)/($Allmailboxes).count) "Generating Report for $AllMailbox"
  auditreport $AllMailbox.DistinguishedName
  $i++
  }
}
else
{
_Progress (70) "Generating Report for $Mailbox"
auditreport $Mailbox
}

Remote logon server query

$
0
0

Hi all,

I have been racking my brain for two days now and I can't seem to find anything on the net that can point me in the right direction. First let me say I'm a novice in PowerShell so any help anyone could provide would greatly be appreciated.

On to my issue.

I have been fiddiling around with PS for 2 days trying to figure out how I can get the logonserver for a remote user and machine.

I know this line will provide my local logonserver $a = $env:logonserver by saving the info to $a

So my script

Function Get-LogonServer {

$username = Read-host "Enter Username"

write-host $username Has Authenticated to Domain Controller $env:LOGONSERVER }  <------ I know this line is not correct as it is only reporting back the server my local account has authenticated to.

Is there away to get remote logonserver info?

I hope this makes sence once again I appreciate anypnes help

TechNet Library syntax error - Using the Compare-Object Cmdlet

$
0
0

There is an error in one of the examples on the following page:
http://technet.microsoft.com/en-us/library/ee156812.aspx

About two thirds of the way down the page is a section introduced with:

Notice that we use the Get-Content cmdlet to retrieve the contents of the two text files, and that each Get-Content command is enclosed in parentheses; that ensures that we pass objects (as opposed to, say, string values) to Compare-Object.  In effect, what we’ve done here is create a single command that encompasses these three individual commands:

$A = Get-Content c:\scripts\x.txt
$B = Get-Content c:\scripts\y.txt
Compare-Object A$ B$

The third line above does not accomplish what is expected.

The correct syntax should be

Compare-Object $A $B

Copy Folders recursive with specific modicication date/time

$
0
0

Hi Guys

Im searching for s script that copy folders recursively from my server to another place with a specific modification date/time.

Copy files from one place to another is easy, only how to create a copy script that only copy specific folders with for example a modification date of 1 day back in time.

hope you guys can help me.

dennis


Script to export users from a specific group and display SamAccountName and AccountIsDisabled

$
0
0

Hi there,

PS newbie!

I want to write a script or a line that will export users from a certain AD group and list/export them in a csv displaying the following 2 attributes:

- SamAccountName

- AccountIsDisabled

Is this possible or any cmdlets/syntax I can play with please?

Thank You

active directory web services binding http

$
0
0

Hi

I will like to know if the Active Directory Web Services have a http-binding for accessing to it, with a java client for example ?
Our Active Directory is 2008R2. If not, is that the 2012 version brings improvements on this point?

Regards

Olivier

Get all AD active users export to CSV by OU

$
0
0

Dear all,

I need your help in orcer to export all AD users from AD by powershell.

I need to export to CSV with all info about the user like ( name, telefone, office, email, address, user logon name, Job Tittle.

I will have to create a separate spredsheet by AD OU ( I have at the rrot of AD countries OUs , so I need to split the scv in diferent files or spreedsheet by OU) , and filter by enabled & disabled account state.

Thanks for your help !!!!!

Get all users in AD Group

$
0
0

Hello.

Iam using this powershell command to list the users in a ad group

Get-ADGroupMember -Identity "Group name" | foreach-object { Write-Host $_.SamAccountName }

and it seems to work just fine.

Here is the problem, i have a group that had no members, i added some members to that group and then i did run this command but it still does not show the users, if i run it on groups that already have members then it list the members.

Does it for some reason takes time before it will show up after that i added users?

Iam running this powershell on the domain controller.

Breaking $Env:Path into an Array of Paths

$
0
0

Hello Sirs,

Is there a way to break the $Env:Path into an Array of Paths; so that I can "divide and rule" them!

load csv file to sql table

$
0
0

  I need to read a folder and process different formatted (csv) files and load to SQL table. THe file format of one
of the csv looks like this:
  (1)                  (2)      3 4  5    6
02-06-2013,10:08:57,0,0,120,30306
02-06-2013,10:09:57,0,4,120,30306


 I need to combine column 1 and 2 and make a datetime. Then take column 3 and 6(first 3 postions) and write record to SQL. I need to create multiple records for the SQL write. The record write to SQL table would be COl1and2 combined then hard coded value (001) then value from col 3 then col 6 first 3 positions. Then I need to repeat that same write to SQL for col 4 but use hard coded (002). Then repeat that same write to SQL for col5 with hard coded value(003). I need to write 3 records to SQL from that one record. The hard coded values are different tests based upon record pos(3,4,5). Pos 3 is always (001) TEST ... Pos 4 is always(002) and Pos 5 is always(003). I would like at the end of reading the input give a small log of file processed and records read and written. I have used PS to load a CSV to SQL before but not with this kind of logic more of a straight load.  Thanks.                                                                                                                                                                                                        

Powershell Set-Acl use without changing owner?

$
0
0
I have a folder, and I am trying to grant full permissions to another user, like so:

$Acl = Get-Acl "C:\MyFolder"

$AccessRule = New-Object  system.security.accesscontrol.filesystemaccessrule("bobby","FullControl", "Allow")
$Acl.AddAccessRule($AccessRule)
Set-Acl -AclObject $Acl "C:\MyFolder"

The owner of the folder is "Joe".
The powershell script runs under the "SyncProcess" account.

If Joe is the owner of the folder, the script fails with the error message:
Set-Acl : The security identifier is not allowed to be the owner of this object

If I change the owner of the folder manually to SyncProcess, then the script runs fine without error.

My question is, why does Set-Acl try to change the owner?  I am not trying to change the owner, nor do I want to.  I read the script to mean, get the current Acl, add the full control permission access rule for Bobby, and then update the folder.  I don't think I am doing anything here to change the owner?

if I add $Acl | fl both before and after the AddAccessRule method call, the Owner is the same in both, unchanged.  Whe does Set-Acl think the owner is changing?

Thanks.


C# - Powershell SDK - How to run a .cmd script from within Runspace?

$
0
0

Hi All,

As I'm new to Powershell programming, started looking for samples in msdn and other sites. Finally I found something exactly what I was looking for at How to run PowerShell scripts from C#. Basically, I want to learn how powershell commands can be executed from C# windows application. Everything was good, until I ran .cmd script which actually sets the environment variables, loads modules and then spawn powershell.exe. This is how my script looks like:

test.cmd:-

@IF "%ECHO%" == "" ECHO OFF
setlocal
set ########

call ################.cmd

call ################.cmd

@echo **** Loading ####### in Powershell *
powershell -sta -noexit "& {;write-host -foregroundcolor green "##### Powershell modules..."; Get-ChildItem -path $env####-Recurse -Filter *.###|%%{if ($env:ARG1 -eq '"-message'") {write-output "importing module $_.fullname"}; ############### Write-IntroMessage}" ***

I've used '#' for all those that are not necessary to understand the problem. Following is the code snippet from above codeproject link:

            Runspace runspace = RunspaceFactory.CreateRunspace();
            runspace.Open();

            Pipeline pipeline = runspace.CreatePipeline();
            pipeline.Commands.AddScript(scriptText);
            pipeline.Commands.Add("Out-String");

            Collection<PSObject> results = pipeline.Invoke();

            runspace.Close();

            StringBuilder stringBuilder = new StringBuilder();
            foreach (PSObject obj in results)
            {
                stringBuilder.AppendLine(obj.ToString());
            }

            return stringBuilder.ToString();

My problem is that when I ran the above script, my C# Winform application never returns and hangs for ever. The above script is actually spawning separate powershell.exe and waiting for it close/exit. I was able to reproduce the issue even with the simple following script:

test.cmd

powershell.exe

As far as I know, any .net windows/console application just acts as a host for powershell engine(not really spawns powershell.exe) where we can execute any powershell command or script. But in my day-to-day work, we do use scripts like above in addition to just running the commands. I tried other samples from codeproject like AyncPowerShell and was able reproduce the issue.

I'm really stuck here. Do I need to use RunSpacePool? I just started powershell programming  so I'm not familiar with all the concepts of it. I think I'm missing something very basic.

Thanks in advance,

Ravi A


Importing CSV and filtering it via TXT file

$
0
0

Hello everyone. Please pardon me if I don't make too much sense with what I'm trying to accomplish. We have a database that extracts data into a CSV file nightly. This database contains a lot of information concerning our physical servers. Whenever we decommission servers we have to fill spreadsheets with information gathered from this CSV file. However, I'm trying to only filter out certain columns and servers (the ones being decommissioned) from the CSV file. 

Here is what I have so far:

$test = Import-CSV ".\aperture_servers.csv" |
Select @{Name="Server Name";Expression={$_."device_name"}},
        @{Name="IP Address";Expression={$_."nic_1_text"}},
        @{Name="ILO IP";Expression={$_."console_ilo_text"}},
        @{Name="Building";Expression={$_."building"}},
        @{Name="Floor";Expression={$_."floor"}},
        @{Name="Grid";Expression={$_."placement_grid"}},
        @{Name="Serial #";Expression={$_."serial_number"}}
        
$test | export-csv new-test.csv –notype

This works fine, however, it extracts EVERY (thousands) of servers into the new-test.csv file. I want to create a servers.txt file that has a list of servers and this way the export-csv command only exports servers that match the servers.txt file. Any help would be appreciated. (Sorry I'm very newb at this stuff).

Enter-PSSession: WinRM cannot process the request, Kerberos authentication error 0x80090322

$
0
0

Hi!

I've configured PowerShell Remoting on the server using Enable-PSRemoting commandlet.

But when I'm trying to connect to the server I'm constantly getting the following error:

PS C:\Users\sergeyp> Enter-PSSession SERVERNAME.DOMAINNAME.com
Enter-PSSession : Connecting to remote server SERVERNAME.DOMAINNAME.com failed with the following error message : WinRM cannot process the request. The following error
with errorcode 0x80090322 occurred while using Kerberos authentication: An unknown security error occurred.
 Possible causes are:
  -The user name or password specified are invalid.
  -Kerberos is used when no authentication method and no user name are specified.
  -Kerberos accepts domain user names, but not local user names.
  -The Service Principal Name (SPN) for the remote computer name and port does not exist.
  -The client and remote computers are in different domains and there is no trust between the two domains.
 After checking for the above issues, try the following:
  -Check the Event Viewer for events related to authentication.
  -Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport.
 Note that computers in the TrustedHosts list might not be authenticated.
   -For more information about WinRM configuration, run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1+ Enter-PSSession SERVERNAME.DOMAINNAME.com+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : InvalidArgument: (SERVERNAME.DOMAINNAME.com:String) [Enter-PSSession], PSRemotingTransportException+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed

Also, in the System event log on a client computer I see the Security-Kerberos error described here:
http://technet.microsoft.com/en-us/library/52ddf7d9-a0e7-4c9d-be3c-3c35219f2d69.aspx

Error details:

Log Name: System Source: Microsoft-Windows-Security-Kerberos Date: 2/22/2013 1:42:39 PM Event ID: 4 Task Category: None Level: Error Keywords: Classic User: N/A Computer: ... Description:

The Kerberos client received a KRB_AP_ERR_MODIFIED error from the server
SERVERNAME$. The target name used was HTTP/SERVERNAME.DOMAINNAME.com.
This indicates that the target server failed to decrypt the ticket
provided by the client. This can occur when the target server principal
name (SPN) is registered on an account other than the account the target
service is using. Please ensure that the target SPN is registered on,
and only registered on, the account used by the server. This error can
also happen when the target service is using a different password for
the target service account than what the Kerberos Key Distribution
Center (KDC) has for the target service account. Please ensure that the
service on the server and the KDC are both updated to use the current
password. If the server name is not fully qualified, and the target
domain (DOMAINNAME.COM) is different from the client domain
(DOMAINNAME.COM), check if there are identically named server accounts
in these two domains, or use the fully-qualified name to identify the
server.
...

And... I have identical WinRM configuration on the other server, and it works fine.

I'm using Windows Server 2008 Standard SP2 and PowerShell 3.0.

I'm logging in as a domain user.

Both client and server are in the same domain.

The SPN HTTP/SERVERNAME.DOMAINNAME.com doesn't exist, but the corresponding SPN also doesn't exist for the computer on which PS Remoting works fine!

Could somebody help me with identification of this error source, please?


Output line separator

$
0
0
I wrote a quick script to query a list of servers to check for active sessions on some terminal servers, but the output is ugly with no line separation between each server.

Is there a way in my script I could echo a line separator between each server output?  See below for an example.....

Thank you for your help.

If there is a better way to get the same output I would be curious to see what is out there.

Rob

SCRIPT - - - - 

$servers = Get-Content -Path C:\Load_Stuff\MonitoringScripts\TS_list.txt
ForEach ($server in $servers) {Get-TSSession -ComputerName $server -state ACTIVE }


OUTPUT - UGLY - - - - 
PS C:\Load_Stuff\MonitoringScripts\PowerShell> .\GetActiveSessionList.ps1

Server          SessionID State           IPAddress       ClientName      WindowStationName UserName
------          --------- -----           ---------       ----------      ----------------- --------
ts01.LOAD.LOCAL 3         Active          10.4.13.149     AT2RIGHT-0015   RDP-Tcp#7         LOAD\User3.2.4_0015
ts01.LOAD.LOCAL 4         Active          10.4.13.187     AT2RIGHT-0025   RDP-Tcp#23        LOAD\User3.2.4_0025
ts02.LOAD.LOCAL 6         Active          10.4.13.177     AT2RIGHT-0038   RDP-Tcp#9         LOAD\User3.2.4_0038
ts02.LOAD.LOCAL 7         Active          10.4.13.209     AT2RIGHT-0049   RDP-Tcp#6         LOAD\User3.2.4_0049


I would like to see something like this to make it easier to read.....

PS C:\Load_Stuff\MonitoringScripts\PowerShell> .\GetActiveSessionList.ps1

Server          SessionID State           IPAddress       ClientName      WindowStationName UserName
------          --------- -----           ---------       ----------      ----------------- --------
ts01.LOAD.LOCAL 3         Active          10.4.13.149     AT2RIGHT-0015   RDP-Tcp#7         LOAD\User3.2.4_0015
ts01.LOAD.LOCAL 4         Active          10.4.13.187     AT2RIGHT-0025   RDP-Tcp#23        LOAD\User3.2.4_0025

******************************************************************************************************************

ts02.LOAD.LOCAL 6         Active          10.4.13.177     AT2RIGHT-0038   RDP-Tcp#9         LOAD\User3.2.4_0038
ts02.LOAD.LOCAL 7         Active          10.4.13.209     AT2RIGHT-0049   RDP-Tcp#6         LOAD\User3.2.4_0049

get-content

$
0
0

How can I tell get-content to only output lines that (as of the moment) are being added to the text file?

my code

get-content locationOfTheFile.txt -wait

seems to load the entire file.I am looking at a log file which are updated very frequently.

Viewing all 2562 articles
Browse latest View live


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