Outlook Add-In invoke command 'remove paragraph formatting (CTRL-Q)'
I want to invoke the Outlook command 'Remove Paragraph Formatting (CTRL+Q)' [1] programmatically at my Add-In. For instance is breaks the blue line on an e-mail reply. Is this possible? The command is not located at the CommandBar.
Jens
[1] CTRL+Q – This removes all paragraph-level formatting—weird indents, line spacing, extra spacing before and after the paragraphs, etc. Again, select the text, hold down your Control key and press the letter Q.
Hi jfrederich,
Base on my test, I found we could call ClearFormatting() method, then call
ClearParagraphAllFormatting() method.
d.Application.Selection.ClearFormatting();
d.Application.Selection.ClearParagraphAllFormatting();
Please try it and check whether this meet your requirement.
Regards
Starain
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Hi Starain, that was my first try. It doesn't work. nothing happens. The blue line resists on the front of the selection.
Jens
Similar Messages
-
Script to add markers to text by paragraph format
With previous versions of Framemaker, I had a FrameScript which would loop through my document and add a marker to text based on the paragraph format applied. The marker text would be the selected paragraph.
I am now trying to recreate this in Extendscript for use in Framemaker 10 and am completely stumped.
I have no doubt that my script (copied below) is completely off-track, but I wondered if anybody would be able to help point me in the direction of my many mistakes.
Basically, I want the script to find all paragraphs with the "*Part no." format applied, make that text the text range and then apply a marker to that range. A bit of research has shown that I probably need to create a list of paragraph formats, but I believe that I have far more problems than just that.
var pgfFmt1 = flow.GetNamedPgfFmt (*Part no.);
while (pgfFmt1.ObjectValid())
function createMarker (doc, pgf, offset, type, text) {
var tRange, marker;
tRange = pgfFmt1.TextRange;
marker = doc.NewAnchoredObject(Constants.FO_Marker, tRange);
marker.MarkerType = type;
marker.MarkerText = text;
return 1;
createMarker (doc, pgf, 0, "Index", 0);
Many thanks in advance to anyone who is able to offer me some pointers!Well, it seems that my script is only 95% there. While my script finds the target paragraphs and adds a marker, only the first word of each paragraph is selected as the marker text. I really need the script to select the whole paragraph as the marker text. I have tried many combinations, but cannot seem to get the right outcome. Could anybody please point me in the right direction? Script is copied below. Many thanks!
var doc = app.ActiveDoc;
var flow = doc.MainFlowInDoc;
var tframe = flow.FirstTextFrameInFlow;
var pgf = tframe.FirstPgf;
var target1 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Part no.");
var target2 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Parent Bold");
var target3 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Child");
var target4 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Child indent");
var target5 = doc.GetNamedObject(Constants.FO_PgfFmt, "*Child indent 2");
while (pgf.ObjectValid()) {
if (pgf.Name == target1.Name) {
createMarker (doc, pgf, 0, "Index", "");
else if (pgf.Name == target2.Name) {
createMarker (doc, pgf, 0, "Subject", "");
else if (pgf.Name == target3.Name) {
createMarker (doc, pgf, 0, "Subject", "");
else if (pgf.Name == target4.Name) {
createMarker (doc, pgf, 0, "Subject", "");
else if (pgf.Name == target5.Name) {
createMarker (doc, pgf, 0, "Subject", "");
pgf = pgf.NextPgfInDoc;
function createMarker(doc, pgf, offset, type, text) {
var tLoc = new TextLoc(pgf, offset);
var marker = doc.NewAnchoredObject(Constants.FO_Marker, tLoc);
var markerType = doc.GetNamedObject(Constants.FO_MarkerType, type);
marker.MarkerTypeId = markerType;
marker.MarkerText = text;
return 1; -
Hi,
I am deplyoing a solution which has custom web parts- vwp- appln pages, event receivers.
It was working fine till last week. I was able to deploy the solution and able to see the web parts and func. was working.
But now from the last 2 days onwards, when I tried to depoy this soution, I am getting the error
"Error occurred in deployment step 'Add Solution': A timeout has occurred while invoking commands in SharePoint host process "
may i know why am getting this error.
note: my dev machine- Win Srvr 2012 - VS 2012- SP 2013 - SP D 2013 was having soem issues with the space in C drive.
once i have done the index reset few months back and i started getting space in C:\ Drive is 0 bytes.
so what my infra. team has done is , increased the space in drive to 150 GB[ it was a VM ].
help is appreciated !What is current disk space on your drives
Delete ULS logs and other log files from server id not needed
could be related to ChannelOperationTimeout
http://msdn.microsoft.com/en-us/library/ee471440(v=vs.100).aspx
Also, don't forget to restart Visual Studio
Goto the following regustry key: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\SharePointTools
Add the following as a DWORD (wont be there by default)
ChannelOperationTimeout
REG_DWORD that specifies the time, in seconds, that Visual Studio waits for a SharePoint command to execute. If the command does not execute in time, a SharePointConnectionException is thrown.
The default is 120 seconds.
http://social.technet.microsoft.com/wiki/contents/articles/21052.como-resolver-o-erro-error-occurred-in-deployment-step-activate-features-a-timeout-has-occurred-while-invoking-commands-in-sharepoint-host-process-pt-br.aspx
If this helped you resolve your issue, please mark it Answered -
Invoke-Command & Add-CMDistributionPoint - Certificate failure
Hi together,
for automatic creation of Distribution Points I am doing the following things.
Doing this locally on the Primary Site Server as Network Access Account everything works fine.
But when I try to do this with invoke-command on my machine with Network Access Account too, I'll get an error:
WARNING: The self signed certificate could not be created successfully.
What am I doing wrong?
Here is what I am doing locally:
Write-Host "------------------NOW Running on REMOTE Primary Site----------------" -BackgroundColor Yellow -ForegroundColor Black
if(!(Test-Path $RemoteSCCMModule))
Write-Error "Could not find Remote SCCM Module!"
Exit
Write-Debug "Importing SCCM Module..."
Import-Module $RemoteSCCMModule -Force
$SiteLocation = $SiteCode + ":"
Set-Location $SiteLocation | Out-Null
if(($BoundaryName -ne "") -and ($BoundaryName -ne " ") -and ($BoundaryName -ne $null) -and ($BoundaryName -ne $false))
$BoundaryValue = $BoundaryStartIP + "-" + $BoundaryEndIP
New-CMBoundary -DisplayName $BoundaryName -BoundaryType IPRange -Value $BoundaryValue
New-CMBoundaryGroup -Name $BoundaryGroupName
Add-CMBoundaryToGroup -BoundaryGroupName $BoundaryGroupName -BoundaryName $BoundaryName
New-CMSiteSystemServer -ServerName $using:NewDPServer -SiteCode $using:SiteCode
Start-Sleep -Seconds 2
Add-CMDistributionPoint -SiteSystemServerName $NewDPServer -SiteCode $SiteCode -MinimumFreeSpaceMB $MinimumFreeDiskSpace -EnablePxeSupport -AllowRespondIncomingPxeRequest -EnableUnknownComputerSupport -ComputersUsePxePassword $PXEPassword -UserDeviceAffinity DoNotUse -PxeServerResponseDelaySeconds 5 -CertificateExpirationTimeUtc $CertExpirationDate
Start-Sleep -Seconds 2
Foreach($DPGroup in $NewDPServer_Groups)
Add-CMDistributionPointToGroup -DistributionPointGroupName $DPGroup -DistributionPointName $NewDPServer
And this is what I am doing with Invoke-Command:
Invoke-Command -ComputerName $PrimarySiteServer -ConfigurationName Microsoft.PowerShell32 -Credential $NAACred -ScriptBlock {
$DebugPreference = $using:DebugPreference
Write-Host "------------------NOW Running on REMOTE Primary Site----------------" -BackgroundColor Yellow -ForegroundColor Black
Write-Debug "Importing SCCM Module..."
Import-Module $using:RemoteSCCMModule -Force
$SiteLocation = $using:SiteCode + ":"
Set-Location $SiteLocation | Out-Null
if(($using:BoundaryName -ne "") -and ($using:BoundaryName -ne " ") -and ($using:BoundaryName -ne $null) -and ($using:BoundaryName -ne $false))
$BoundaryValue = $using:BoundaryStartIP + "-" + $using:BoundaryEndIP
New-CMBoundary -DisplayName $using:BoundaryName -BoundaryType IPRange -Value $BoundaryValue
New-CMBoundaryGroup -Name $using:BoundaryGroupName
Add-CMBoundaryToGroup -BoundaryGroupName $using:BoundaryGroupName -BoundaryName $using:BoundaryName
New-CMSiteSystemServer -ServerName $using:NewDPServer -SiteCode $using:SiteCode
Start-Sleep -Seconds 2
Add-CMDistributionPoint -SiteSystemServerName $using:NewDPServer -SiteCode $using:SiteCode -MinimumFreeSpaceMB $using:MinimumFreeDiskSpace -EnablePxeSupport -AllowRespondIncomingPxeRequest -EnableUnknownComputerSupport -ComputersUsePxePassword $using:PXEPassword -UserDeviceAffinity DoNotUse -PxeServerResponseDelaySeconds 5 -CertificateExpirationTimeUtc $using:CertExpirationDate
Start-Sleep -Seconds 2
Foreach($DPGroup in $using:NewDPServer_Groups)
Add-CMDistributionPointToGroup -DistributionPointGroupName $DPGroup -DistributionPointName $using:NewDPServer
If you need more information what different valus of variables are i can provide.
Thank you.
Kind regards
Martin KrämerHi,
Here is the whole script - I'm still testing around this is why it is not really nice at the moment ;-) :
$DebugPreference = "Continue"
$Script:Script= $MyInvocation.MyCommand.Definition
$Script:DebugOut = "Script started: " + "$Script:Script"
Write-Debug $Script:DebugOut
$Script:ScriptPath = Split-Path -Path $Script:Script -Parent
$CertExpirationDate = (Get-Date).AddYears(100)
#region Setting_Variables
$NAACred = Get-Credential -Message "provide NetworkAccessAccount credentials:" -UserName "test.loc\NAA_User"
[string]$RemoteSCCMModule = "D:\ConfigMgr\AdminConsole\bin\ConfigurationManager.psd1"
[string]$PrimarySiteServer = "Test-Primary"
[string]$SiteCode = "KN1"
[string]$NewDPServer = "TEST-DP.test.loc"
$PXEPassword = ConvertTo-SecureString -AsPlainText "mypass" -Force
[int]$MinimumFreeDiskSpace = 2000
[string]$BoundaryName = " "
[string]$BoundaryStartIP = "192.168.30.1"
[string]$BoundaryEndIP = "192.168.30.254"
[string]$BoundaryGroupName = "TEST-DP_Group"
[array]$NewDPServer_Groups = "04 All Aviable DPs", "01 All PXE DPs"
#endregion Setting_Variables
#region REMOTE PrimarySiteServerScript
<#
IF ($env:PROCESSOR_ARCHITECTURE -ne "x86")
Write-Debug "Powershell needs to be in x86 mode. Restarting powershell..."
$PS32exe = "$env:windir\SysWOW64\WindowsPowerShell\v1.0\powershell.exe"
if(!(Test-Path $PS32exe))
Write-Error "x86 Powershell not found!"
exit
$powershell = [System.Diagnostics.Process]::GetCurrentProcess()
$psi = New-Object System.Diagnostics.ProcessStartInfo $powerShell.Path
$script = $MyInvocation.MyCommand.Path
$prm = $script
foreach($a in $args)
$prm += ' ' + $a
$psi.Arguments = $prm
$psi.FileName = $PS32exe
[System.Diagnostics.Process]::Start($psi) | Out-Null
exit
Else
Write-Debug "Powershell already in x86 mode..."
if(!(Test-Path $using:RemoteSCCMModule))
Write-Error "Could not find Remote SCCM Module!"
Exit
#>
<#
Invoke-Command -ComputerName $PrimarySiteServer -ConfigurationName Microsoft.PowerShell32 -Credential $NAACred -ScriptBlock {
$DebugPreference = $using:DebugPreference
Write-Host "------------------NOW Running on REMOTE Primary Site----------------" -BackgroundColor Yellow -ForegroundColor Black
Write-Debug "Importing SCCM Module..."
Import-Module $using:RemoteSCCMModule -Force
$SiteLocation = $using:SiteCode + ":"
Set-Location $SiteLocation | Out-Null
if(($using:BoundaryName -ne "") -and ($using:BoundaryName -ne " ") -and ($using:BoundaryName -ne $null) -and ($using:BoundaryName -ne $false))
$BoundaryValue = $using:BoundaryStartIP + "-" + $using:BoundaryEndIP
New-CMBoundary -DisplayName $using:BoundaryName -BoundaryType IPRange -Value $BoundaryValue
New-CMBoundaryGroup -Name $using:BoundaryGroupName
Add-CMBoundaryToGroup -BoundaryGroupName $using:BoundaryGroupName -BoundaryName $using:BoundaryName
New-CMSiteSystemServer -ServerName $using:NewDPServer -SiteCode $using:SiteCode
Start-Sleep -Seconds 2
Add-CMDistributionPoint -SiteSystemServerName $using:NewDPServer -SiteCode $using:SiteCode -MinimumFreeSpaceMB $using:MinimumFreeDiskSpace -EnablePxeSupport -AllowRespondIncomingPxeRequest -EnableUnknownComputerSupport -ComputersUsePxePassword $using:PXEPassword -UserDeviceAffinity DoNotUse -PxeServerResponseDelaySeconds 5 -CertificateExpirationTimeUtc $using:CertExpirationDate
Start-Sleep -Seconds 2
Foreach($DPGroup in $using:NewDPServer_Groups)
Add-CMDistributionPointToGroup -DistributionPointGroupName $DPGroup -DistributionPointName $using:NewDPServer
#>
#endregion REMOTE PrimarySiteServerScript
#region LOCAL PrimarySiteServerScript
Write-Host "------------------NOW Running on REMOTE Primary Site----------------" -BackgroundColor Yellow -ForegroundColor Black
if(!(Test-Path $RemoteSCCMModule))
Write-Error "Could not find Remote SCCM Module!"
Exit
Write-Debug "Importing SCCM Module..."
Import-Module $RemoteSCCMModule -Force
$SiteLocation = $SiteCode + ":"
Set-Location $SiteLocation | Out-Null
if(($BoundaryName -ne "") -and ($BoundaryName -ne " ") -and ($BoundaryName -ne $null) -and ($BoundaryName -ne $false))
$BoundaryValue = $BoundaryStartIP + "-" + $BoundaryEndIP
New-CMBoundary -DisplayName $BoundaryName -BoundaryType IPRange -Value $BoundaryValue
New-CMBoundaryGroup -Name $BoundaryGroupName
Add-CMBoundaryToGroup -BoundaryGroupName $BoundaryGroupName -BoundaryName $BoundaryName
New-CMSiteSystemServer -ServerName $using:NewDPServer -SiteCode $using:SiteCode
Start-Sleep -Seconds 2
Add-CMDistributionPoint -SiteSystemServerName $NewDPServer -SiteCode $SiteCode -MinimumFreeSpaceMB $MinimumFreeDiskSpace -EnablePxeSupport -AllowRespondIncomingPxeRequest -EnableUnknownComputerSupport -ComputersUsePxePassword $PXEPassword -UserDeviceAffinity DoNotUse -PxeServerResponseDelaySeconds 5 -CertificateExpirationTimeUtc $CertExpirationDate
Start-Sleep -Seconds 2
Foreach($DPGroup in $NewDPServer_Groups)
Add-CMDistributionPointToGroup -DistributionPointGroupName $DPGroup -DistributionPointName $NewDPServer
#endregion LOCAL PrimarySiteServerScript
Thank you for help :-) -
Suppress file deletion confirmation on remote server in Invoke-Command
Hi!
I try create function used for removing folders (and all content) on remote servers .
$FullPathToDelete="\\"+("$Computername\$BasePath\$FolderToDelete").Replace("\\","\")
if (Test-Path $FullPathToDelete -pathType container ) {
$ScriptBlockContent = {
paramater($FullPathToDeleteLocal)
Get-ChildItem -Path $FullPathToDeleteLocal -Recurse | Remove-Item -Force $true -Recurse $true -Confirm:$false | Out-Null
Invoke-Command -Computername $Computername -ScriptBlock $ScriptBlockContent -ArgumentList $FullPathToDelete -AsJob
Remove-Item -Path $FullPathToDelete -Force | Out-Null
Example values for variables
$Computername = "SPPL09281"$BasePath="D$"$FolderToDelete="FolderName"
All work but for every computer (I use this code in a loop) I receive additional prompt for confirmation
Id Name State HasMoreData Location Command
11 Job11 Running True SPPL09281 ...Confirm
The item at Microsoft.PowerShell.Core\FileSystem::\\SPPL09281\D$\FolderName has children and the Recurse
parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to
continue?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
How I can avoid these confirmation prompts?
Thank you in advance.
Wojciech SciesinskiHi Wojciech,
In addition, The original confirm is reminding the folder you want to delete has subfiles, please try to add -recurse parameter:
$FullPathToDelete="\\"+("$Computername\$BasePath\$FolderToDelete").Replace("\\","\")
if (Test-Path $FullPathToDelete -pathType container ) {
$ScriptBlockContent = {
paramater($FullPathToDeleteLocal)
Get-ChildItem -Path $FullPathToDeleteLocal -Recurse | Remove-Item -Force -Recurse -Confirm:$false | Out-Null
Invoke-Command -Computername $Computername -ScriptBlock $ScriptBlockContent -ArgumentList $FullPathToDelete -AsJob
Remove-Item -Path $FullPathToDelete -Recurse -Force
If there is anything else regarding this issue, please feel free to post back.
If you have any feedback on our support, please click here.
Best Regards,
Anna Wang
TechNet Community Support -
Is there a way to make invoke-command interactive?
Hello,
I have a script that runs an invoke-command with multiple arguments and performs operation on a remote workstation.
I want to add some additional confirmations and dialogue choices depending on how the script block executes on the remove PC.
Is there a way to do that?I'm afraid it's not possible in my scenario.
I'm using invoke-command with Credssp authentication because I need to execute a number of commandlets that are only installed on a specific remote server. Those powershell commandlets from Microsoft do not work if installed on the client.
Those commandlets use network share resources too, that's why Credssp is used.
During the execution of invoke-command I wanted to make an additional confirmation for overwriting of some resources.
The other option is to run several invoke-commands and get output from the queries, construct the dialogue options based on those queries and gather input locally and then run the final execute invoke-command last, but it seems just like too much of
hassle for now, so i'll leave things as they are. -
Hello,
I have a problem with logging on multiple servers at the same time. I would like to have a single file with every log formated like this :
"yyyyMMdd HH:mm:ss - $Env:ComputerName - result of the command"
To know what computer is doing what, I am currently logging in separate files on each server running the following code :
$ExecDate = Get-Date -Format yyyy-MM-dd_HH-mm
$TroncateLocalLogFileName = "C:\Temp\$ExecDate"
$ScriptBlock= {
Param ($TroncateLocalLOgFileName)
Get-Date
Echo *****************
Write-Host "Blablabla is running on" $Env:ComputerName ", please wait..."
Echo "Blablabla is running, please wait..."
& "C:\Program Files\firstscript.ps1"
Echo *****************
Echo "Enabling BLABLABLA for $env:computername..."
Set-ItemProperty -Path HKLM:\MyRegistryPath -name MyRegistryKey -Value 1
Echo *****************
Echo "End of procedure"
Write-Host "BALBALBLA for" $env:computername "is done"
Echo *****************
Get-Date
} > $TroncateLocalLOgFileName"_$Env:ComputerName.log" 2>&1
invoke-command -ComputerName $ListOfServers -ArgumentList $TroncateLocalLogFileName -ScriptBlock $ScriptBlockforeach ($Computer in $ListOfServers) {
robocopy \\$Computer\$LogSource $LogDestination\ $Execdate"_*" /MOV
Does anyone knows how to add some string to output inside an Invoke-Command to get the required result ?
I tried everything I could think of without anything getting near...
Thanks in advance for your help.Hi Pierre,
If you want to export the result to a single log file instead of mutiple log files located on every remote computers, please try to export the log file outside the scriptblock of the the cmdlet "Invoke-Command", and use the cmdlet "Out-File"
to append every result from remote computers to a single file:
$ExecDate = Get-Date -Format yyyy-MM-dd_HH-mm
$TroncateLocalLogFileName = "C:\Temp\$ExecDate"
$ScriptBlock= {
Param ($TroncateLocalLOgFileName)
Get-Date
Echo *****************
Write-Host "Blablabla is running on" $Env:ComputerName ", please wait..."
Echo "Blablabla is running, please wait..."
& "C:\Program Files\firstscript.ps1"
Echo *****************
Echo "Enabling BLABLABLA for $env:computername..."
Set-ItemProperty -Path HKLM:\MyRegistryPath -name MyRegistryKey -Value 1
Echo *****************
Echo "End of procedure"
Write-Host "BALBALBLA for" $env:computername "is done"
Echo *****************
Get-Date
invoke-command -ComputerName $ListOfServers -ArgumentList $TroncateLocalLogFileName -ScriptBlock $ScriptBlock | out-file $TroncateLocalLOgFileName"_$Env:ComputerName.log" -append
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang -
Cannot send email from Outlook 2010 without disabling iCloud Outlook Add-in
I have seen a few discussions on this but no answers. I have bought a new PC. Installed Outlook 2010 and iCloud latest version 3. All seems to work fine but emails go into the Outbox and dont get any further. If I remove the iCloud Outlook Add-in then I can send my emails but of course now cannot see my contacts nor my calendar! So it's one or the other and I'm currently going backwards and forwards between each. I have uninstalled and gone back to an earlier version 2 of iCloud with no success, same problem. I have uninstalled that and now reinstalled version 3. The problem remains. Can you advise on how to solve this please?
Then it has nothing to do with iCloud, contact Bell and if they can't help, Microsoft
-
How to remove values formatting in export to excel from ALV grid
Hi all,
I have small issue, I have ALV Grid with some data, but the problem is with columns containing e.g. gross amounts, because it is displayed in the grid as e.g. 1.764,81, and after export to excel it is still in this format (with dot and comma), so excel doesn't treat it as numeric value but as text, and then when I try to calculate total on the column then this values are not taken to the total. Do you know if that is possible to remove column formatting?
kind regards,
MarcinI replied too soon to Peter's suggestions. For some reason, I was able to add new info. to my first new row, but not the second. However, I finally figured out the problem.
I found the Help Center page on: "Here are ways to change custom formats and apply changes to table cells:"
To change the elements associated with a custom format that’s been applied to cells, select the cells and click Show Format in the Format pane of the Table inspector.
I saw that the "cell format" was listed as "automatic," so I changed it to "Custom;" then left the new custom window at it's default settings. Now my cells would accept pasted info. without spreading it through the lower rows. Whatever automatic was in the table, it was not what I wanted. Doing this to other new cells, solved my problem. Thanks again. -
Run invoke-command on multiple machines at the same time
Hey all so I read that if I store my New-pssession in a variable then used that in my invoke-command it would run all computers at the same time.
$a = Get-Content "C:\Users\cody-horton\Desktop\list.txt"
$session
for($i=0;$i -lt $a.Length;$i++){
if(!(Test-Connection -Cn $a[$i] -BufferSize 16 -Count 1 -ea 0 -quiet)){
Write-Host $a[$i] -foregroundcolor red
else{
$session = New-PSSession $a[$i]
Invoke-Command -Session $session -FilePath "\\My computer\C`$\Users\public\Documents\zip folder.ps1"
What exactly am I doing wrong I just need to run this script on multiple machines at the same time.
Thanks.
Edit: Also what would be the best way to close all the sessions thanks.Hi there,
So what I think you are doing wrong here is that you are overwriting the value in $Session everytime you executed code inside for loop. try the below:
$a = Get-Content "C:\Users\cody-horton\Desktop\list.txt"
$session = @() #define this as an array
for($i=0;$i -lt $a.Length;$i++){
if(!(Test-Connection -Cn $a[$i] -BufferSize 16 -Count 1 -ea 0 -quiet)){
Write-Host $a[$i] -foregroundcolor red
else{
$session += New-PSSession $a[$i] #add the new session to the array, at the end it will be a collection of sessions
Invoke-Command -Session $session -FilePath "\\My computer\C`$\Users\public\Documents\zip folder.ps1" #I think the above one won't work..first you need to copy the script locally on the machine and then execute it#Why this won't work because of Second-Hop Authentication
Have put comments where I edited your code.
Hope this helps
Knowledge is Power{Shell}. http://dexterposh.blogspot.com/ -
How to create paragraph format in smartforms
Hi All,
Let me know how to create paragraph format in smartforms?
Thanks&Regards
MaheshHi
When we create a smartform we can see in <b>global settings</b> , <b>form attributes</b>.
In <b>form attributes</b> we set the over all style of the smartform. Goto <b>form attributes</b> and open the tab <b>output options</b>. Here you can see the <b>Style box</b>. In this style box we enter the smartstyle created in transaction code <b>smartstyles</b>.
Open transaction <b>smartstyles</b>.
Create a new style.
Upon creating a new style you will see 3 folder structures under style name.
1. Header data
2. Paragraph format
3. Character format
To create paragraph format right click on the paragraph format node and click Create Node. Give it name. Now you will get a screen with 4 tabs.
Indents and spacing
Fonts
Tabs
Numbering and outline
Here you can provide the look you want.
Now add this smartstyle in your smartform's form attribute.
You can also provide individual smartstyles to each text element you create by giving the name of smartstyle in its output options tab. Each text element has a individual output option tab here you can give any smartstyle.
Click on the general attribute tab of any text element and give the paragraph format directly or by going to SAPScript editor mode.
Any more questions you can ask me directly mailing me.
Please do reward points if satisfied. -
How can you run a command with elevated rights on a remote server with invoke-command ?
I am trying to run a script on a remote server with invoke-command. The script is starting and is running fine, but the problem is that it should be running with elevated rights on the remote server. On the server where I start the invoke-command, my account has the necessary rights.
The server were I launch the invoke-command is a W2K8 R2. The remote box is a W2K3 with powershell v2.0 installed.
When I launch the script on the remote-box from the command line, I don't get the access denied's.
Is there a way to do this ?
Thanks in advanceThe script that I want to run is to install the windows updates. I get an access denied on the download of the updates.
When I execute the script on an W2K8 box, (not remotely) and I run it with non-elevated rights, I get the same error.
The script is running fine when it is launched on W2K3 box locally with a domain account that has local admin rights, or on a W2K8 R2 server with a domain account that has local admin rights, but with elevated rights.
Thanks in advance for your help.
#=== start script ====
param($installOption="TESTINSTALL",$rebootOption="NOREBOOT")
Function Show-Help
Write-Host ""
Write-Host "SCRIPT: $scriptName <installOption> <RebootOption>"
Write-Host ""
Write-Host "DESCRIPTION: Installatie van WSUS updates op de lokale server"
Write-Host ""
Write-Host "PARAMETERS"
Write-Host " -installOption <[INSTALL|TESTINSTALL]>"
Write-Host " -rebootOption <[REBOOT|NOREBOOT|REBOOT_IF_UPDATED]>"
Write-Host ""
Write-Host "EXAMPLE:"
Write-Host "$ScriptName -installOption INSTALL -rebootOption REBOOT_IF_UPDATED"
Write-Host "$ScriptNAme INSTALL NOREBOOT"
Write-Host ""
Write-Host "Indien beide parameter weggelaten worden zijn de defaultwaarden :"
Write-Host " installOption=TESTINSTALL "
Write-Host " RebootOption=NOREBOOT"
Write-Host ""
Exit
#Include alle globale variablen
$CEIF_WIN_PATH = (get-content env:CEIF_WIN_PATH)
$includeFile=$CEIF_WIN_PATH + "\Scripts\include_win.ps1"
. $includeFile
#initialiseer error count
$errcnt=0
$scriptName=$MyInvocation.MyCommand.Name
#argumenten controleren
$arrInstallOption= "TESTINSTALL", "INSTALL" # Mandatory variable with predefined values
If (!($arrInstallOption –contains $installOption)){ Show-Help }
$arrRebootOption = "REBOOT", "NOREBOOT","REBOOT_IF_UPDATED" # Mandatory variable with predefined values
If (!($arrRebootOption –contains $rebootOption)){ Show-Help }
#Logfile opbouwen
$logfile = get-logfileName($MyInvocation.MyCommand.Name)
Log-scriptStart $MyInvocation.MyCommand.Name $logfile
function Get-WIAStatusValue($value)
switch -exact ($value)
0 {"NotStarted"}
1 {"InProgress"}
2 {"Succeeded"}
3 {"SucceededWithErrors"}
4 {"Failed"}
5 {"Aborted"}
function boot-server()
if ($installOption -eq "TESTINSTALL")
logger "TESTINSTALL : - Reboot local Server" $logfile
else
logger " - Reboot local Server" $logfile
$thisServer = gwmi win32_operatingsystem
$thisServer.psbase.Scope.Options.EnablePrivileges = $true
$thisServer.Reboot()
$logmsg="Install option = " + $installOption + ", RebootOption = $rebootOption"
logger "$logmsg" $logfile
logger "" $logfile
logger " - Creating WU COM object" $logfile
$UpdateSession = New-Object -ComObject Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
logger " - Searching for Updates" $logfile
$SearchResult = $UpdateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
logger " - Found [$($SearchResult.Updates.count)] Updates to Download and install" $logfile
$Updates=$($SearchResult.Updates.count)
logger "" $logfile
foreach($Update in $SearchResult.Updates)
if ($Update.EulaAccepted -eq 0)
$Update.AcceptEula()
# Add Update to Collection
$UpdatesCollection = New-Object -ComObject Microsoft.Update.UpdateColl
$UpdatesCollection.Add($Update) | out-null
if ($installOption -eq "TESTINSTALL")
else
# Download
logger " + Downloading Update $($Update.Title)" $logfile
$UpdatesDownloader = $UpdateSession.CreateUpdateDownloader()
$UpdatesDownloader.Updates = $UpdatesCollection
$DownloadResult = $UpdatesDownloader.Download()
$Message = " - Download {0}" -f (Get-WIAStatusValue $DownloadResult.ResultCode)
if ($DownloadResult.ResultCode -eq 4 )
{ $errcnt = 1 }
logger $message $logfile
# Install
logger " - Installing Update" $logfile
$UpdatesInstaller = $UpdateSession.CreateUpdateInstaller()
$UpdatesInstaller.Updates = $UpdatesCollection
$InstallResult = $UpdatesInstaller.Install()
$Message = " - Install {0}" -f (Get-WIAStatusValue $InstallResult.ResultCode)
if ($InstallResult.ResultCode -eq 4 )
{ $errcnt = 1 }
logger $message $logfile
logger "" $logfile
#Indien er een fout gebeurde tijdens download/installatie -> stuur mail naar windowsteam
if ( $errcnt -gt 0 )
logger " - Fout tijdens de uitvoering van script -> send mail" $logfile
$mailSubject=$MyInvocation.MyCommand.Name
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($logfile)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = $mailFrom
$msg.To.Add($mailTo)
$msg.Subject = $mailSubject
$msg.Body = “Meer details in attachement”
$msg.Attachments.Add($att)
$smtp.Send($msg)
#Moet de server herstart worden ?
if ($rebootOption -eq "REBOOT_IF_UPDATED" )
if ($Updates -gt 0)
#Reboot the server when updates are installed
boot-server
elseif ($rebootOption -eq "REBOOT")
#reboot the server always
boot-server
else
#Do not reboot the server
logger "Do not reboot the server" $logfile
Log-scriptEnd $MyInvocation.MyCommand.Name $logfile
exit 0 -
For SAPscript INCLUDE TEXT, how to align as Paragraph format
Hi experts and ABAP colleagues!
Need your help on this sapscript problem:
How to align texts taken from "INCLUDE TEXT" in SAPscript, according to tab defined in Paragraph Format?
For example, I defined BG to have tabstop at the 2nd column (or equivalent to 1st tab position) where I need to print the text, and then declared it in SE71 like below:
However the text prints at the leftmost instead of at the 2nd col position - (8th char tab defined in par. format BG). Hence it is not aligned to its proper heading. Line Number instead of Description - which is not okay for client view that needs these Thai texts.
The technical details I included below. Kindly examine:
1.) Window >Main > Text Element > Include Text command
/E ITEM_TEXT
BG ,,&TTXIT-TDTEXT&
/: INCLUDE &T166P-TXNAM& OBJECT &T166P-TDOBJECT& ID &T166P-TDID&
/: NEW-PARAGRAPH BG
Note: I used command "NEW-PARAGRAPH" and had exactly the above code in se71. Anything missed here? Pls. help. Thanks.
#2.) Paragraph Format > Tab
No. -
Tab Position -
Alignment
1 8,00 CH LEFT
2 28,00 CH CENTER
etc.
Note: and then i put in ",,&TTXIT-TDTEXT&" (see above) with the 2 comma's beforehand to say that its on the 1st tab or at the 8th character where it should be printed, but does not give intended result... pls help.
#3.) Paragraph Formats > Standard Attributes
Left Margin - 0 cm
Alignment - Left
no blank lines checkbox - ticked
Note: Is there any more attribute i can manipulate from here to force display at the right position?
Thank you so much in advance for all your help. Our project team will really appreciate it. May the Lord bless you as we go through our SAP work!
Sincerely,
CelesteHere's a thought, instead of using tabs, try writing a method that takes a string that is the starting string, a pad character, and a length and returns a string padded to that length with the specified character.
public String padR(String src, String padChar, int len)
// ... You get to fill in the rest suggestion try to do it without a loop
}Have fun,
PS. -
Invoke-Command and ShellId Issues
Hi all,
I'm struggling to figure out what is going on here.
I'm trying to add a domain user to a VM's local administrators group via this:
$localAdminBlock = `
$objUser = [ADSI]("WinNT://domain/domainaccount")
$objGroup = [ADSI]("WinNT://$vm/Administrators")
$objGroup.PSBase.Invoke("Add",$objUser.PSBase.Path)
Invoke-Command -ComputerName $vm -Scriptblock $localAdminBlock -Credential $adminCreds
I receive an error:
"Processing data from remote server TestServer failed with the following error message: The request for the Windows Remote Shell with ShellId <id here> failed because the shell was not found on the server. Possible causes are: the specified
ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation..."
Any idea what's going on?
Thanks.You need to use $using:vm instead of $vm since you are passing a value from a local variable into the scriptblock which
is executed remotely. If you don't do this then the $vm will be $null in the remote session. If you use $using:vm then Invoke-Command will evaluate the local $vm variable and use this value in the remote session.
$localAdminBlock = `
$objUser = [ADSI]("WinNT://domain/domainaccount")
$objGroup = [ADSI]("WinNT://$using:vm/Administrators")
$objGroup.PSBase.Invoke("Add",$objUser.PSBase.Path)
Invoke-Command -ComputerName $vm -Scriptblock $localAdminBlock -Credential $adminCreds
--Neptune
That was the issue, thanks a lot! -
Use of "Next paragraph same page" check box in paragraph format of SCRIPT?
Hi Guys,
What is the use of "Next paragraph same page" check box in paragraph format of SCRIPT?
Don't Send me the F1 help ....i am not clear with that help it is quite confusing.
Provide example if possible.
Solutions will be rewarded.
Regards,
GURUHello.
You probably know the idea of PROTECT command. It makes that a paragraph wont break in two. If it fit's totaly in one page it will print in that page. If not, it will print totaly in the second page (won't break at the middle).
The checkbox you are asking, makes the same with two paragraphs. This means that if you have paragraphs A and B (A becomes first) and if paragraph A has that option, the next paragraph won't break, and appear in the second page. If paragraph A is in first page, paragraph B will print in first page too, or they will both print in second page.
Try it.
Best regards.
Valter Oliveira.
Maybe you are looking for
-
Data transfer from SAP R/3 to SQL Server
Can anybody help me. I will explain the scenario. If there is any change or update in the HR master data like creation of new personnel number or deletion of personnel number and change of cost center etc., should immediately get reflected in the S
-
Apple Mail & Keychain in OD Envoirement, Bug or Feature?
Hello I have sorted out a bug (or hidden feature) by using Apple Mail in an Open Directory environment. When using the Open Directory for storing the home folders of the user, the password for Apple Mail are not stored in the default "login" but stor
-
Growing nsure audit log file in sys\etc\logcache
I have a Netware 6.5 OES2 server that suddenly had a quickly growing file in the \sys\etc\logcache folder. The file has just recently stabilized, but I would like to shrink the file. I am aware that this is part of NSure auditing and would like to le
-
hello all, Currently i am working on POC for FI and PS integration. hence needed the POC documents or templates for my reference please do send them asap if u have any. thnx®ards, Shylini.p
-
I do not have Elements. Can I run Premier alone or with Photoshop 6 or CC
A simple question, I do not have Elements and want to learn video. Can I run Premier alone or with Photoshop 6 or CC? Thank for you help. Roy