How to bring a prompt to User sitting on a laptop/desktop using Power shell command/script before machine gets rebooted.
Hi Experts,
I am a novice in Powershell and trying to learn PowerShell.
Currently, i need to reboot some 50-60 desktops remotely.
i am using the below powershell command
gc c:\Temp\machineList.txt |%{Restart-computer -computername $_ -force}
It is working perfect for me but what i want is before machine gets rebooted User should get a prompt like "Your machine will be rebooted in 60 seconds, Please save your work".
How i can achieve this in a powershell script.
Thanks in advance.
Daya
an other option is to start taskmanager on Domain Controller
go to users right click user Object send message
regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com
"taskmanager"?
That only works for users logged into the dc. Users should not be allowed to log into the DC directly.
I suspect you mean to use the MSG facility if it is not disabled. MSG /?. This can send messages to uses on various systems.
¯\_(ツ)_/¯
Similar Messages
-
How to get site permissions using power shell ?
Hello,
I require to get list of granted permissions ( Group/users ) which we see from Site Actions > Site Permissions.
would you please let me know how can I fetch the same using power shell ?
Thanks and Regards,
Dipti ChhatrapatiHello,
I have found the same using following script :
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
#Define variables
$site = Get-SPSite "Site collection URL"
#Get all subsites for site collection
$web = $site.AllWebs
#Loop through each subsite and write permissions
foreach ($web in $web)
if (($web.permissions -ne $null) -and ($web.hasuniqueroleassignments -eq "True"))
Write-Output "****************************************"
Write-Output "Displaying site permissions for: $web"
$web.permissions | fl member, basepermissions
elseif ($web.hasuniqueroleassignments -ne "True")
Write-Output "****************************************"
Write-Output "Displaying site permissions for: $web"
"$web inherits permissions from $site"
Write-Host "Finished."
$site.dispose()
$web.dispose()
Hope it helps others !
Thanks and Regards,
Dipti
Dipti Chhatrapati -
How to Execute Power Shell Command From Windows Application.
Hi All Experts,
I want to execute power shell commands from my windows application.
Is it possible ?
Please let me know your comments..
Thanks.I have not tried this, but apprently it is easy as in the sample pasted below. please see this article for more details
http://geekswithblogs.net/Norgean/archive/2012/09/19/running-powershell-from-within-sharepoint.aspx.
Let me know how it goes...
public string RunPowershell(string powershellText, SPWeb web, string param1, string param2) {
// Powershell ~= RunspaceFactory - i.e. Create a powershell context
var runspace = RunspaceFactory.CreateRunspace();
var resultString = new StringBuilder();
try
// load the SharePoint snapin - Note: you cannot do this in the script itself (i.e. add-pssnapin etc does not work)
PSSnapInException snapInError;
runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out snapInError);
runspace.Open();
// set a web variable.
runspace.SessionStateProxy.SetVariable("webContext", web);
// and some user defined parameters
runspace.SessionStateProxy.SetVariable("param1", param1);
runspace.SessionStateProxy.SetVariable("param2", param2);
var pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(powershellText);
// add a "return" variable
pipeline.Commands.Add("Out-String");
// execute!
var results = pipeline.Invoke();
// convert the script result into a single string
foreach (PSObject obj in results)
resultString.AppendLine(obj.ToString());
finally
// close the runspace
runspace.Close();
// consider logging the result. Or something.
return resultString.ToString();
Ok. We've written some code. Let us test it.
var runner = new PowershellRunner();
runner.RunPowershellScript(@"
$web = Get-SPWeb 'http://server/web' # or $webContext
$web.Title = $param1
$web.Update()
$web.Dispose()
", null, "New title", "not used");
-Sangeetha -
Any good Power Shell command or script to see connected users in real time for Lync 2013
Are there any good Power Shell commands or scripts that can tell you how many users are connected to a pool in real time so you can evaluate the current load. I have 3 FE servers in a single pool. We just started deploying the lync client to the users and
were curious as to how many are actually connected. I saw a number of home made scripts but really didn't care for any of them. I just want to find out how many users that are actually connected to the pool at a particular moment so we can see how many users
are really using the product.Have you looked at Pat Richard's get-csconnections script?: http://www.ehloworld.com/269
Please mark posts as answers/helpful if it answers your question.
Blog
Lync Validator - Used to assist in the validation and documentation of Lync Server 2013. -
How to run 'Get-AssignedAccess' or 'Set-AssignedAccess' power shell commands in c# Application
Hi,
I have console application using which i am trying to run power shell command like 'Get-AssignedAccess' or 'Set-AssignedAccess'.
i am using below code for this it is throwing exception 'Get-AssignedAccess' doesn't exist in cmdlet which is correct because these commands belongs to function category.
using (PowerShell pwInstance = PowerShell.Create())
pwInstance .AddScript("Get-AssignedAccess");
var result = pwInstance .Invoke();
How can we execute this kind of command using c#?
Thanks,Hi prakashlight,
Thank you for comming back and tell us the result. For more information about how to run PowerShell script in C# language, you can refer to this blogpost here:
Executing PowerShell scripts from C#
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. -
Using Power shell script how to hidden SharePoint existing features.
Hi Firends,
Using Power shell script how to hidden SharePoint existing features.
Please help me.
Thanks,
Tiru
TiruThe Hidden property is set within the solution, so you would need access to the source code in order to set it.
Trevor Seward
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
How do I copy pictures from IPad Air to my laptop without using the Cloud?
How do I copy pictures from IPad Air to my laptop without using the Cloud?
See this link: Import photos and videos from your iPhone, iPad, or iPod touch to your Mac or Windows PC - Apple Support
http://support.apple.com/en-us/HT201302
Import media to a Windows PC
Before importing your media:
Unlock your iOS device using your passcode, particularly if you've never synced your device with the computer before. Learn more about iOS passcodes.
Makes sure your iOS device trusts the computer you want to import your media onto. Learn more about "Trust this Computer."
Windows 8: Learn how to import photos and videos from a camera, phone, or DVD (Windows Help)
Windows 7 and Windows Vista: Learn how to get pictures from your camera to your computer(Windows Help)
If your computer doesn't recognize an attached iPhone, iPad, or iPod touch as a camera, and prevents you from importing photos to your computer, learn how to resolve the issue. -
I have sideloaded a windows 8.1 app for mutiple
users in the device using the following command in windows power shell:-
DISM /Online /Add-ProvisionedAppxPackage /PackagePath:”packagepath” /SkipLicense
Now i want to un-install the same app for mutiple
users in windows 8.1 since i want to install latest package of that app but i am not able to un-install the app for mutiple
users in windows 8.1 using windows power shell
This is what i have tried :-
DISM.exe /Online /Remove-ProvisionedAppxPackage /PackageName: "PackageFullName"
This what the error i am getting:-
Deployment Image Servicing and Management tool
Version: 6.3.9600.17031
Image Version: 6.3.9600.17031
Error: 2
The system cannot find the file specified.
The DISM log file can be found at C:\Windows\Logs\DISM\dism.log
Am i missing anything ??
1)How to un-install a specific app for mutiple users in windows 8.1 using windows power shell??????
2)What are the variousways/Alternatives to un-install a specific app for mutiple users in windows 8.1 using windows power shell??????
Please let me know
Looking forward for your response
Thanks in advanceI am getting the same error, though I have verified the package name is correct. I am trying to uninstall the Reader App from a captured WIM (offline). Any suggestions?
dism /image:c\mount Get-ProvisionedAppxPackage Result:
DisplayName : Microsoft.Reader
Version : 2013.822.1823.785
Architecture : neutral
ResourceId : ~
PackageName : Microsoft.Reader_2013.822.1823.785_neutral_~_8wekyb3d8bbwe
Attempt to remove the app returns this same error message:
C:\WINDOWS\system32>dism /image:c:\mount /remove-provisionedappxpackage /Package
Name:Microsoft.Reader_2013.822.1823.785_neutral_~_8wekyb3d8bbwe
Deployment Image Servicing and Management tool
Version: 6.3.9600.17031
Image Version: 6.3.9600.17031
Error: 2
The system cannot find the file specified.
The DISM log file can be found at C:\WINDOWS\Logs\DISM\dism.log
The error is accompanied by the following entries in the error log:
2015-04-14 12:44:53, Error DISM DISM Appx Provider: PID=9000 TID=8104 Failed to get staged packages for package 'Microsoft.Reader_2013.822.1823.785_neutral_~_8wekyb3d8bbwe'.
- CPackageAdapter::CreateForRemove(hr:0x80070002)
2015-04-14 12:44:53, Error DISM DISM Appx Provider: PID=9000 TID=8104 Failed while initializing package adapter for package 'Microsoft.Reader_2013.822.1823.785_neutral_~_8wekyb3d8bbwe'
- CAppxManager::RemoveAllUserAppx(hr:0x80070002)
2015-04-14 12:44:53, Error DISM DISM Appx Provider: PID=9000 TID=8104 Failed to remove package 'Microsoft.Reader_2013.822.1823.785_neutral_~_8wekyb3d8bbwe'
- CAppxManager::ProcessCommandRemoveAllUserAppx(hr:0x80070002)
2015-04-14 12:44:53, Error DISM DISM Appx Provider: PID=9000 TID=8104 Failed processing command to remove Appx package - CAppxManager::ExecuteCmdLine(hr:0x80070002) -
How to load excel files from my SharePoint site to Excel client by using Power Query
Hello,
I am using Power Query to import some Excel files from shared documents on SharePoint site. After I type the URL of my SharePoint site into the filed, the expected Excel files do not appear in Power Query. Please provide the method as soon as possible.
Thanks!Could you check if
this post can help? -
Hello,
I created a package in Visual Studio Integration Services, where it runs successfully.
I then deployed it to SQL server 2012. Here to it runs successfully, too.
Then I changed the script in that I exchanged two variables for two parameters - doing the same thing.
I noticed that in VS no dialog window comes up where I could change the value of the parameters; here obviously I am expected to set them in Visual Studio.
However, in SQL Server 2012 the dialog window does come up when I execute the package. I can then change the value of my two parameters and the package runs OK, giving me the expected results.
Now I created a script in SQL Server from which to execute the package. Do I have to change the script every time when I want it to run with different values for the parameters?
So far I have not even found how to feed different values for the parameters into the package by using the script. Or could I tell the script somehow to bring up the dialog window for changing the parameters?
How can I set/change the package parameters by using an SSIS execution script in SQLserver?
Or how could I bring up the dialog window thru the script?
Would s.o have an example?
Help is greatly appreaciated.
Thank you
AndreasHi,
I found out by myself and leave the answer here should s.b. else wonder about the same issue.
Look at this:
Declare
@var0 sql_variant
= 1
Exec
[SSISDB].[catalog].[set_execution_parameter_value]
@execution_id,
@object_type=30,
@parameter_name='MaxPosition',
@parameter_value=@var0
Declare
@var1 nvarchar
= 'x'
Exec
[SSISDB].[catalog].[set_execution_parameter_value]
@execution_id,
@object_type=30,
@parameter_name='NameContains',
@parameter_value=@var1
Now, what is important and was not evident to me is:
1) The variable you use for the parameters - here var0 and var1 must match in their data type the corresponding parameter used in the package.
2) The @parameter_name must match the corresponding parameter name in the package.
3) The value that is being passed to the respective package parameter is the value you specify in the Declare statement. So in my case a string x and an int 1 is used.
4) Of course the @object_type must be set to 30 for package parameters
Then the script runs the package with adjusted parameters.
To many this might be evident, to me it was not.
Cheers
Andi
Andreas -
How to create a 'Link to a Document' Item in a SharePoint Document Library using power shell?
Hi,
I have a document library with "Link to a document" content type. And, I have to add some links into that library using powershell. I have searched enough regarding approachs for adding a link into the library in powershell but i did not get anything yet.
Please provide some approaches and code samples to solve this problem.
Thanks,
Lalit Kumar MishraAdding Site Columns To Content Types Using PowerShell
Adding Site Columns To Content Types Using PowerShell
The below PowerShell script will allow you to add a metadata field that is either contained at the Site Collection level, Site level, or library level, to the specified Content Type.
It also contains some optional lines that you might choose to include or exclude, such as
Setting the visibility of the column in the edit form to hidden
Setting the status of the column to require values
01
function Add-SPContentTypeField
02
03
<#
04
.Synopsis
05
This function will allow you to add a library field to a Content
Type
06
.Description
07
This function will add the nominated site column/ library column to a nominated Content
Type within all of the 'Document Libraries'
in the given Site Collection
08
.Example
09
C:\PS>Add-SPContentTypeField
–SiteUrl “http://yourdomain.com/sites/Finance –FieldName
"myField" -CTypeAddedTo "myContentType"
10
.Notes
11
Name: Add-SPContentTypeField
12
Author: Petro Margaritis
13
Last Edit: 19/07/2012
14
Keywords: Fields, Site Columns, Content Types
15
.Link
16
http://thesharepointproject.com/
17
#>
18
19
Param (
20
[parameter(Mandatory=$true)][string]$SiteUrl,
21
[parameter(Mandatory=$true)][string]$FieldName,
22
[parameter(Mandatory=$true)][string]$CTypeAddedTo
23
24
25
$site = Get-SPSite
$SiteUrl
26
27
# Walk through each site in the site collection
28
$site | Get-SPWeb
-Limit all | ForEach-Object {
29
30
write-host
"Checking site:"$_.Title -Foregroundcolor
Green
31
32
# Go through each document library in the site
33
foreach
($list in $_.Lists | where
{ $_.BaseTemplate -eq "DocumentLibrary" })
34
35
36
# Check to see if the library contains the content type we are looking for
37
if (($list.ContentTypes |
where { $_.Name -eq $CTypeAddedTo
}) -eq $null)
38
39
Write-Host
"The Content:" $CTypeAddedTo "does not exist in the library:"
$list.Title -Foregroundcolor Red
40
41
else
42
43
# Check to see if the library contains the field we are looking for
44
if (($list.Fields |
where { $_.Title -eq $FieldName
}) -ne $null)
45
46
# Get the content type you want to add the field to
47
$ct
= $list.ContentTypes[$CTypeAddedTo]
48
# Get the column you want to copy
49
$field
= $list.Fields[$FieldName]
50
# Add the column to the content type
51
$ct.Fieldlinks.Add($field)
52
$ct.update()
53
54
# Add additional column settings
55
$ctFieldLinks
= $ct.FieldLinks | Where
{$_.Name -eq $field.Title}
56
# OPTIONAL: This will set the column to hidden so that it is not viewable in the edit form
57
$ctFieldLinks.Hidden =
$true
58
# Set Field to require value
59
$ctFieldLinks.Required =
$true
60
$ct.Update()
61
Write-Host
"The Field:" $field.Title "has been successfully added to the library:"
$list.Title -Foregroundcolor Cyan
62
63
else
64
65
Write-Host
"The Field:" $FieldName "does not exist in the library:"
$list.Title -Foregroundcolor Yellow
66
67
68
69
70
# Dispose of the site object
71
$site.Dispose()
72
Simply copy and paste the above into Notepad and save it as a PowerShell file with the name
Add-SPContentTypeField.ps1
view sourceprint?
1
# To run the above function you'll need to do the following - go into the saved location
2
Cd C:\scripts\
3
# Then call it using the dot prefix - note that there is a space between the dots, ..\
4
. .\Add-SPContentTypeField.ps1
5
# Now we can happily run the script like so
6
Add-SPContentTypeField –SiteUrl “http://yourdomain.com/sites/Finance –FieldName
"myField" -CTypeAddedTo "myContentType" -
[Solved] stumpwm: how to get rid of newline using run-shell-command
Hi all,
in order to set up my mode-line for stumpwm, I've been using the commad
run-shell-command such as in:
(setf *screen-mode-line-format*
(list
'(:eval (run-shell-command "date" t))
'(:eval (run-shell-command "date" t))))
However, each instance of run-shell-command creates an unnecessary
newline (so that my mode line contains two lines without necessity).
Do you know how I can get rid of this newline?
Thanks!
Last edited by falsum (2011-05-23 07:12:27)jiyuu wrote:
I didn't test it but the function you want is 'string-trim' or 'string-right-trim'.
You use it like this:
(string-trim '(#\Newline) my-string)
So in your case:
(setf *screen-mode-line-format*
(list
'(:eval (string-trim '(#\Newline)
(run-shell-command "date" t)))
'(:eval (run-shell-command "date" t))))
That works perfectly well. Thanks a lot jiyuu!! -
Add existing site content type to doc lib -power shell
Add-PSSnapIn Microsoft.SharePoint.PowerShell
#Update : incomplete on 09-feb-2015 05 pm
$siteCollecURL = "http://sirvr11:123/sites/Engineering/WIP"
$basicContentType="Basic Content Type"
#$siteColl = Get-SPSite -Identity $siteCollecURL
$paramWeb = Get-SPWeb -Identity $siteCollecURL
Write-Host $siteColl.Url
$pdoclib ="CY"
$docLib = $paramWeb.Lists[$pdoclib]
$docLib.Title
if ($docLib -ne $null)
$docLib.ContentTypesEnabled = $true
$docLib.Update()
#Add site content types to the list
$ctToAdd = $paramWeb.ContentTypes["Basic Content Type"]
$ctToAdd.Name
pause
try
$ct = $docLib.ContentTypes.Add($ctToAdd)
catch
write-host "error adding Content type" $ct.Name "to" $docLib.Title
write-host "Content type" $ct.Name "added to list" $docLib.Title
$docLib.Update()
am trying to add the "BasicContent Type" to my doc lib called "CY" with the help of above power shells cript.
but it failed to add .
getting the error message.can anyone pls help where am missing any steps /line of code.
help is appreciated!Hi,
try the following
#Get site object and specify name of the library to look for in each site
$site = Get-SPSite http://portal
$lookForList = "Shared Documents"
#Walk through each site and change content types on the list specified
$site | Get-SPWeb -Limit all | ForEach-Object {
write-host "Checking site:"$_.Title
#Make sure content types are allowed on the list specified
$docLibrary = $_.Lists[$lookForList]
if ($docLibrary -ne $null)
$docLibrary.ContentTypesEnabled = $true
$docLibrary.Update()
#Add site content types to the list
$ctToAdd = $site.RootWeb.ContentTypes["Sales Document"]
$ct = $docLibrary.ContentTypes.Add($ctToAdd)
write-host "Content type" $ct.Name "added to list" $docLibrary.Title
$ctToAdd = $site.RootWeb.ContentTypes["IT Document"]
$ct = $docLibrary.ContentTypes.Add($ctToAdd)
write-host "Content type" $ct.Name "added to list" $docLibrary.Title
$docLibrary.Update()
else
write-host "The list" $lookForList "does not exist in site" $_.Title
#Dispose of the site object
$site.Dispose()
Kind Regards,
John Naguib
Technical Consultant/Architect
MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation
Please remember to mark your question as answered if this solves your problem -
At times I type in a site name on the command line which I want to visit. This goes into a file which is accessed by highlighting the triangle on the right side of command line. This file contains previous sites which were accessed in the past. How do I edit this file and and remove previous site URLs?
Use these steps to remove saved (form) data from a drop down list:
#Click the (empty) input field on the web page to open the drop down list
#Highlight an entry in the drop down list
#Press the Delete key (on Mac: Shift+Delete) to remove it.
*http://kb.mozillazine.org/Deleting_autocomplete_entries
*https://support.mozilla.com/kb/Clearing+Location+bar+history
*https://support.mozilla.com/kb/Cannot+clear+Location+bar+history -
How do I refer to a user defined field in a query (using $ notation) ?
if i have a user defined field in Invoice header called U_Test, and if I need to read it using a query (to be used on a formatted search).
I am not quite sure of the syntax. can anyone help please?
I tried
$[$U_Test.0.0] which is the accepted way with fields with numerical ids such as $[$8.0.0] etc.
appreciate any help,
Indika.Hi all,
Aliw, the 38 is not the form number, is the Item Number (which I guess is a matrix). In your case the User Defined Field is a line UDF. In Indika´s case is a header UDF.
And that´s the issue. As the indika´s UDF is a header UDF, it lays in a different form (which is named "-" + Main Form Name). Formatted searches work with the $[$Field.Column.Format] notation ONLY in the same form. So, if you try to get the UDF from another UDF, it will work with that notation (they are in the same form). But if you try to get the UDF from the main form, it won´t find it (It is in another form).
In that case you should use the other notation, as Andrea, Alexey and Salvador told you in the posts before.
Hope this clears a bit the issue.
Regards,
Ibai Peñ
Maybe you are looking for
-
Hi there-- Just got the Sony PXW-X70 and I can't seem to open the .mxf or even successfully transcode the video files into something that can be read on the mac. (Running 10.9.5) I downloaded Brorsoft Video Converter for Mac and the Ackrock Video Con
-
Pinkish Color cast in iphoto 08 ?
Hi everyone, I recently purchased a new mac with ilife 08. I noticed in iphoto that when i double click on a picture and it enlarges it, i get a pinkish color cast over the picture. it does it with all the pictures in iphoto. the thumbnails in iphoto
-
After install oracle 10g, enterprise manager web version, can not login
Hi Guru, I have installed oracle 10g on windows xp pro sp2 successfully, can use sqlplus to connect to DB, but when using IE to login enterprise manager web version port 1158, it failed. The login page came out, but when I keyed in the right userid/p
-
I'm creating a page that uses a Spry Data Set for a book I'm working on. I have no problem with the data set when viewing the page in IE9 beta and Safari. Two separate testers who are using IE8 get the same error: "type="MM_SPRY_DATA_REFERENCE" ....
-
Vcast Media Manager won't play some songs after Correcting Song Info
I recently installed Vcast MM 1.1 build 11 (most recent version that I see). I imported all my local media into MM just fine. However, after using the 'Correct Song Info' feature, several songs no longer play in the MM player. Before using this featu